-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCorduroy_DAQ_main.ipf
executable file
·1335 lines (1077 loc) · 51.7 KB
/
Corduroy_DAQ_main.ipf
1
#pragma rtGlobals=2 // Use modern global access method.///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CORDUROY_DAQ_main// Please see READ-ME for relevant notes and information////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_LaunchCorduroyDAQ()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DoWindow/K Table0 string restoreDF = GetDataFolder(1) NVAR launches = root:DAQ:General:launches fDAQmx_ResetDevice(StringFromList(0,fDAQmx_DeviceNames())) if( !(NVAR_exists(launches)) ) NewDataFolder/O root:DAQ NewDataFolder/O root:DAQ:General // Begin initializing all the global variables and the DAQ board CORD_InitializeDAQGlobals() CORD_CreatePaths() variable/G root:DAQ:General:launches = 1 // Initialize the XML-based data logging system CORD_DisplayELN() // DAQ requires that some of the analysis variables be present as well (specifically modules) CORD_InitializeUtilityVars() CORD_InitializeAnalysis() CORD_InitializeModules() CORD_MakeDAQPersonalWindow() // Sets up telegraphing and what not CORD_InitializeAmpClasses() else launches += 1 endif CORD_MakeControlPanel() CORD_InitializeDisplays() CORD_DisplayChannels() CORD_UpdateRecWaves() CORD_DisplayProtocolPanel() SetDataFolder restoreDF NVAR TelCheck = root:DAQ:Classes:Amplifiers:TelLogic print " " print " " print "----------------------------------------------------" print "Launching Data acquisition and performing a system check" print date() print "----------------------------------------------------" print "System configured with NI device: "+StringFromList(0,fDAQmx_DeviceNames()) print "Amplifier capable of telegraphing? "+num2str(TelCheck) print "----------------------------------------------------" print "NOTE: PFI0 is used as a start of sweep trigger and can be used for synchronization" print "Resetting the device to initialize..." End // LaunchCorduroyDAQ/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_InitializeDAQGlobals()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// String thisDF = GetDataFolder(1) NewDataFolder/O root:DAQ NewDataFolder/O/S root:DAQ:General Make/T/O/N=1 recWaves; recWaves[0]="none" String/G root:DAQ:General:gactiveprot = "none" String/G root:DAQ:General:curr_sweep= "0" String/G root:DAQ:General:gactivesweeps = "1" String/G root:DAQ:General:gactivechanIn = "0" String/G root:DAQ:General:gactivechanOut = "0" String/G root:DAQ:General:associatedmod = "none" string/G root:DAQ:General:baseName = "f"+CORD_ParseDate(Secs2Date(DateTime,-1)) SVAR baseName = root:DAQ:General:baseName string tmp1 = baseName+"_0" String/G root:DAQ:General:gactivefile = tmp1 String/G root:DAQ:General:Channel_A = "Multiclamp700B" String/G root:DAQ:General:Channel_B = "Multiclamp700B" String/G root:DAQ:General:Channel_C = "None" String/G root:DAQ:General:Channel_D = "None" NewDataFolder/O root:DAQ:Classes NewDataFolder/O root:DAQ:Classes:Amplifiers NewDataFolder /O root:DAQ:Protocols NewDataFolder /O root:DAQ:DynamicClamp Variable/G root:DAQ:General:SweepNum = 0 Variable/G root:DAQ:General:FileCnt = 0 Variable/G root:DAQ:General:KillSignal = 0 Variable/G root:DAQ:General:period = 40 Variable/G root:DAQ:General:gkilldef = 0 Variable/G root:DAQ:General:averaging = 1 Variable/G root:DAQ:General:SampleRate = 30 String/G root:DAQ:General:gdlmark = "Whole-cell" SetDataFolder thisDF End // InitializeDAQGlobals/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_MakeControlPanel()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DefaultFont/U "Verdana" DoWindow/F CORD_MainPanel if (V_Flag!=0) DoWindow/K CORD_MainPanel endif Execute "CORD_MainPanel()" Execute "ModifyPanel cbRGB = (20000,20000,20000)" End // MakeControlPanel/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_GetDataFolderList()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string DFList="" variable i for(i=0;i<=(CountObjects("",4)-1);i+=1) DFList += GetIndexedObjName("",4,i) DFList +=";" print num2str(i)+" "+GetIndexedObjName("",4,i) endfor print "DFList: "+DFList End // GetDataFolderList/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_DisplayControl(cntrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string cntrlName ControlInfo /W=CORD_MainPanel DisplayList1 variable SelectedListNumber = V_Value WAVE/T recWaves = root:DAQ:General:recWaves if(V_Value==0) if(stringmatch(recWaves[0],"none")) Abort "No data has yet been recorded..." endif endif SVAR baseName = root:DAQ:General:baseName string FullFolderName = "root:"+baseName+"_"+num2str(SelectedListNumber) strswitch(cntrlName) case "DisplayButton1": FullFolderName = "root:"+baseName+"_"+num2str(DimSize(recWaves,0)-1) CORD_DisplayDataFolder(FullFolderName) break case "DisplayButton2": CORD_DisplayDataFolder(FullFolderName) break case "DisplayButton3": KillDataFolder $FullFolderName break case "DisplayButton4": CORD_AssociatedAnalysis(FullFolderName) break endswitch CORD_UpdateRecWaves() End // DisplayControl/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_AssociatedAnalysis(FullFolderName)/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// The purpose of this function is to load and run an associated analysis module for a given protocol.// The association of a module with a protocol is done through the protocol generator. string FullFolderName // Confirm that the analysis ROI manager is already launched DoWindow/F CORD_AnalysisControlPanel if (V_Flag==0) CORD_DisplayAnalysisPanel(0) endif// Find the selected wave and move to its data folder SetDataFolder $FullFolderName // Plot waves in top analysis/viewer graphs CORD_DisplayDataFolder(FullFolderName) // Second step is to execute the associated analysis module SVAR associatedmod = associatedmod Execute associatedmod // Once module has been used to set up appropriate structure execute the analysis CORD_AnalysisPanelRun() End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_DisplayDataFolder(FolderName)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string FolderName SetDataFolder FolderName string ChanA = WaveList("RecordA*",";","") string ChanB = WaveList("RecordB*",";","") DoWindow/K ChannelA DoWindow/K ChannelB DisplayWaveListOneChannel(ChanA,1) // Function is in the analysis family of procedure files if(ItemsInList(ChanB)!=0) DisplayWaveListOneChannel(ChanB,2) endif DoWindow/F ChannelA End // DisplayDataFolder/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_ACQ_main(cntrlName) : ButtonControl/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Button control function that defines the actions of the record and play buttons in the main panel string cntrlName NVAR KillSignal = root:DAQ:General:KillSignal NVAR SweepNum = root:DAQ:General:SweepNum NVAR SaveToggle = root:DAQ:ProtocolPanel:SaveToggle // Test to make sure there is an active protocol to use SVAR activeProt = root:DAQ:ProtocolPanel:activeProt if(stringmatch(activeProt,"none")) Abort "Please select an active protocol before trying to record data." endif // Test to make sure you are not currently recording for all buttons except || BackgroundInfo variable running = V_flag strswitch(cntrlName) case "MainButton1": if(running<2) FIFOStatus /Q TheFIFO if(V_FIFORunning!=0) fDAQmx_ScanStop("Dev1") // Make sure to turn off the FIFO to prevent an error CtrlFIFO TheFIFO, stop endif SaveToggle = 0 CORD_ACQ_background(0) endif break case "MainButton2": if(running<2) FIFOStatus /Q TheFIFO if(V_FIFORunning!=0) fDAQmx_ScanStop("Dev1") // Make sure to turn off the FIFO to prevent an error CtrlFIFO TheFIFO, stop endif SaveToggle = 1 CORD_ACQ_background(1) endif break case "MainButton3": if(running==2) KillSignal = 1 endif break// case "MainButton4":// if(running<2)// SaveToggle = 2// CORD_ACQ_background(2)// endif// break endswitch // Update the file name SVAR CurrActiveFile = root:DAQ:General:gactivefile NVAR FileCnt = root:DAQ:General:FileCnt SVAR baseName = root:DAQ:General:baseName CurrActiveFile = baseName+"_"+num2str(FileCnt)End //CORD_ACQ_main/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_ACQ_background(SaveToggle) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// This is the main function that controls protocol-based background acquisition variable SaveToggle // If any channels are monitoring turn off variable index=0 string ChanList = "A;B;C;D" string MonStateG = "root:DAQ:Classes:Displays:MonState_A"// Get the global state value and stop if running NVAR MonState = $MonStateG if(MonState ==1) MonState = !MonState CORD_monACQ(MonState) string Titles = "monitor;pause" Button TheChart_ON title=StringFromList(MonState,Titles) endif // Get the active protocol from the global variable created by the ProtocolPanel SVAR activeProt = root:DAQ:ProtocolPanel:activeProt string activeProtFolder = "root:DAQ:Protocols:"+activeProt+":" SetDataFolder activeProtFolder// Get some relevant information from the protocol NVAR InterSweepInterval = interlude NVAR samplerate = samplerate// Lookup the global for the number of files created to get the next file and avoid overwrite NVAR FileCnt = root:DAQ:General:FileCnt// Get the global file name for the particular day's experiments SVAR baseName = root:DAQ:General:baseName// Reset the kill signal NVAR KillSignal = root:DAQ:General:KillSignal KillSignal = 0// Get the associated global variable defining the number of sweeps in the protocol NVAR numSweep = numSweep // At this point should go through and kill the displayed waves in a given channel and clear the dataBuffer CORD_CleanupPreviousRecordings()// Update the amp state // TELEGRAPHING UPDATE REQUIRED CORD_ReadAmpState("Multiclamp700B",0)// This runs in the background so that control over other windows can send a kill signal SetBackground CORD_ACQ_pulsed() CtrlBackground start, period=round(InterSweepInterval*60), noBurst=1 End // CORD_ACQ_background/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_ACQ_pulsed()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// NVAR SaveToggle = root:DAQ:ProtocolPanel:SaveToggle // Reference a global that controls which sweep to run NVAR SweepNum = root:DAQ:General:SweepNum variable index = SweepNum SVAR display_sweep = root:DAQ:General:curr_sweep // Get the basename and notebook name for various important references SVAR baseName = root:DAQ:General:baseName SVAR nbname = root:DAQ:General:NB_Name // Some necessary waves need to be created string/G updatetxt = "", OutputCmdString="", ReadInWaves="", SetSeqCmd="", SAndSCmd="", segname="", wavname="" string Channels = "A;B;C;D" // Get necessary info from the protocol df NVAR numSweep = numsweep NVAR samplerate = samplerate SVAR DASeq = DASeq SVAR ADSeq = ADSeq // Continue or kill the recordings NVAR KillSignal = root:DAQ:General:KillSignal if(KillSignal == 1) fDAQmx_ScanStop("Dev1") fDAQmx_WaveformStop("Dev1") fDAQmx_WriteChan("Dev1", 0, 0.0, -0.1,1) fDAQmx_WriteChan("Dev1", 1, 0.0, -0.1,1) if(SaveToggle!=0) CORD_SaveRecordBinary() else SweepNum = 0 display_sweep = num2str(SweepNum+1) endif return 1 // tells the backgrounder to quit endif // Make sure everything was found correctly if(!(NVAR_Exists(numSweep)+NVAR_Exists(samplerate)+NVAR_Exists(KillSignal)+SVAR_exists(DASeq)+SVAR_exists(ADSeq)+WaveExists(out))==6) print "Some mistake has been found in the protocol directory. May want to restart Corduroy or re-create the protocol from the generator." return 1 // tells the backgrounder to quit endif NVAR FileCnt = root:DAQ:General:FileCnt// Create the necessary inwaves CORD_PrepInwaves(DASeq,ADSeq,index) // Generate the string that describes the waves to read in variable StrIndex=0 for(StrIndex=0;StrIndex<strlen(ADSeq);StrIndex+=1) if(StrIndex>0) ReadInWaves += " " endif ReadInWaves += "Record"+StringFromList(str2num(ADSeq[StrIndex]),Channels)+num2str(index)+", "+ADSeq[StrIndex]+";" endfor// To allow a user to rescale the stimuli online need a conditional here where you can specify the output waves in a unique way NVAR rescale = root:DAQ:General:rescale if(!NVAR_Exists(rescale)) variable/G root:DAQ:General:rescale = 0 endif if(rescale) string DefaultSeg="", ScaledSeg="" NVAR OnlineScaleFactor = root:DAQ:General:OnlineScaleFactor // Generate the scaled output waves and the command string StrIndex=0 for(StrIndex=0;StrIndex<strlen(DASeq);StrIndex+=1) DefaultSeg = "seg_"+num2str(index)+"_"+DASeq[StrIndex] ScaledSeg = "sc_seg_"+num2str(index)+"_"+DASeq[StrIndex] WAVE DSegWave = $DefaultSeg Duplicate/O DSegWave, $ScaledSeg WAVE SSegWave = $ScaledSeg SSegWave*=OnlineScaleFactor print "running with rescaled version" if(StrIndex>0) OutputCmdString += " " endif OutputCmdString += "sc_seg_"+num2str(index)+"_"+DASeq[StrIndex]+", "+DASeq[StrIndex]+";" endfor else // Generate the output command string here StrIndex=0 for(StrIndex=0;StrIndex<strlen(DASeq);StrIndex+=1) if(StrIndex>0) OutputCmdString += " " endif OutputCmdString += "seg_"+num2str(index)+"_"+DASeq[StrIndex]+", "+DASeq[StrIndex]+";" endfor endif variable last = 0 if(SweepNum == (numSweep-1)) last = 1 endif String HookStr = "CORD_AcquireHook("+num2str(index)+","+num2str(last)+","+num2str(SaveToggle)+")" // Push the PFI0 digital line to high to signal start of sweep DAQmx_DIO_Config /DEV="Dev1" /DIR=1 /LGRP=1 "/Dev1/port2/line0" Variable/G TaskIndex = V_DAQmx_DIO_TaskNumber ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// MAIN ACQ COMMANDS NVAR averaging = root:DAQ:General:averaging if(averaging==1) DAQmx_Scan /DEV="Dev1" /TRIG={"/Dev1/ao/starttrigger"} /AVE=2 /EOSH=HookStr /BKG WAVES=ReadInWaves else DAQmx_Scan /DEV="Dev1" /TRIG={"/Dev1/ao/starttrigger"} /EOSH=HookStr /BKG WAVES=ReadInWaves endif DAQmx_WaveformGen /DEV="Dev1" /NPRD=1 OutputCmdString fDAQmx_DIO_Write("Dev1",TaskIndex, 1) if (GetRTError(1)) // 1 to clear the error and allow continued execution print fDAQmx_ErrorString() endif////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Pull the PFI0 digital lines back down to zero to indicate the end of the sweep fDAQmx_DIO_Write("Dev1",TaskIndex, 0) fDAQmx_DIO_Finished("Dev1", TaskIndex) // Update sweep count in display display_sweep = num2str(SweepNum+1) ControlUpdate /W=CORD_MainPanel ActiveProt3a// Decide whether this is the last sweep or whether looping of the protocol should continue if(SweepNum == (numSweep-1)) return 1 // tells the backgrounder to quit else SweepNum +=1 // Update the global sweep tracker return 0 // tells the backgrounder to keep cycling endif End // CORD_ACQ_pulsed()//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Function CORD_PrepInwaves(DASeq,ADSeq,index)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CHECK FOR LARGE NUMBERS OF INPUT RECORDINGS string DASeq string ADSeq variable index string segname="", wavname="" variable StrIndex=0, ADindex=0 string Channels = "A;B;C;D" for(StrIndex=0;StrIndex<strlen(DASeq);StrIndex+=1) segname = "seg_"+num2str(index)+"_"+DASeq[StrIndex] for(ADindex=0;ADindex<strlen(ADSeq);ADindex+=1) wavname = "Record"+StringFromList(str2num(ADSeq[ADindex]),Channels)+num2str(index) WAVE local = $segname Duplicate/O local, $wavname endfor endforEnd//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Function CORD_AcquireHook(index,last,SaveToggle)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// variable index variable last variable SaveToggle variable jindex=0 string CurrWaveName ="" NVAR SweepNum = root:DAQ:General:SweepNum SVAR display_sweep = root:DAQ:General:curr_sweep// Create a wave list string wildcard = "Record*"+num2str(index) string list = WaveList(wildcard,";","")// Scale the incoming waves SVAR protstate = protstate variable protTypeFlag strswitch(protstate) case "IC": protTypeFlag = 1 break case "VC": protTypeFlag = 0 break endswitch for(jindex=0;jindex<ItemsInList(list);jindex+=1) CurrWaveName = StringFromList(jindex, list) WAVE local = $CurrWaveName NVAR ChAscaling = root:DAQ:Classes:Amplifiers:Channel_A_scaling NVAR ChBscaling = root:DAQ:Classes:Amplifiers:Channel_B_scaling local = local / ChAscaling endfor// Create a buffer and store the lab notebook data if(index==0) KillDataFolder/Z dataBuffer NewDataFolder/O dataBuffer CORD_UpdateELNdata(1) WAVE/T AmpSettings = root:ExpDetails:AmpSettings Duplicate/O AmpSettings, :dataBuffer:AmpSettings WAVE/T ELNvalues = root:ExpDetails:ELNvalues Duplicate/O ELNvalues, :dataBuffer:ELNvalues WAVE/T ELNlabels = root:ExpDetails:ELNlabels Duplicate/O ELNlabels, :dataBuffer:ELNlabels endif// Move the list CORD_MoveList(list,":dataBuffer:") // Display the parsed inwaves in their appropriate windows CORD_DisplayInWave(index)// Decide whether this the last acquired wave and stop acquisition and save if it is. if(last) fDAQmx_ScanStop("Dev1") fDAQmx_WaveformStop("Dev1") fDAQmx_WriteChan("Dev1", 0, 0.0, -0.1,1) fDAQmx_WriteChan("Dev1", 1, 0.0, -0.1,1) if(SaveToggle!=0) CORD_SaveRecordBinary() else SweepNum = 0 display_sweep = num2str(SweepNum+1) endif endif End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_MoveList(list,target)/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// the string target must end in a : -- see the MoveWave help file for details about syntax string list string target string thisWave="" variable list_len = ItemsInList(list), index=0 for(index=0;index<list_len;index+=1) thisWave = StringFromList(index, list) Wave local = $thisWave MoveWave local, $target endforEnd //MoveList/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// A function required to send the inwave, following parsing to the display panel in correct channelFunction CORD_DisplayInWave(index)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// variable index // Initialize necessary variables used in the for loop NVAR numChanIn = numChanIn SVAR ADseq = ADseq if(strlen(ADSeq)>numChanIn) numChanIn = strlen(ADSeq) endif string RecordName="", ChannelName="", RemoveName="" variable loopIndex string ChannelList = "A;B;C;D;E;F;G;H" string TraceNames="" variable i // Go through each channel and send the current record to the channel plot for(loopIndex=0;loopIndex<numChanIn;loopIndex+=1) ChannelName = "Channel_"+StringFromList(loopIndex,ChannelList) RecordName = ":dataBuffer:Record"+StringFromList(loopIndex,ChannelList)+num2str(index) WAVE local = $RecordName // Check to make sure this channel has a window, otherwise create one DoWindow/F $ChannelName if(V_Flag==0) // This does not make sense, should relaunch the traceplots if this is true Display local as ChannelName DoWindow/C $ChannelName else // just another check to make sure there are no waves already displayed TraceNames = TraceNameList(ChannelName,";",1) if(index==0) if(strlen(TraceNames)>0) for(i=0;i<ItemsInList(TraceNames);i+=1) RemoveFromGraph/Z/W=$ChannelName $(StringFromList(i,TraceNames)) endfor endif endif ModifyGraph/W=$ChannelName rgb=(60928,60928,60928) AppendToGraph/W=$ChannelName local endif SetAxis/W=$ChannelName /A bottom endfor End // DisplayInWave/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_CleanupPreviousRecordings()/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Initialize necessary variables used in the for loop NVAR numChanIn = numChanIn string ChannelName="" variable loopIndex, i string ChannelList = "A;B;C;D;E;F;G;H" string TraceNames="" // Go through each channel and send the current record to the channel plot for(loopIndex=0;loopIndex<numChanIn;loopIndex+=1) // Clear out the correct channel ChannelName = "Channel_"+StringFromList(loopIndex,ChannelList) // Check to make sure this channel has a window, otherwise create one DoWindow/F $ChannelName // Get all the displayed traces and remove them from the graph TraceNames = TraceNameList(ChannelName,";",1) if(strlen(TraceNames)>0) for(i=0;i<ItemsInList(TraceNames);i+=1) RemoveFromGraph/W=$ChannelName $(StringFromList(i,TraceNames)) endfor endif endfor // Finally kill the dataBuffer to get rid of the unnecessary waves KillDataFolder/Z dataBuffer End // Cleanup/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_SaveRecordBinary()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// NVAR FileCnt = root:DAQ:General:FileCnt string origDF = GetDataFolder(1)// Need to move all the recorded waves into a new directory with known structure SVAR baseName = root:DAQ:General:baseName string NewFold = baseName+"_"+num2str(FileCnt) string FoldPath = "root:"+NewFold+":" string NewFile = baseName+"_"+num2str(FileCnt) // Moved data folder into main root directory MoveDataFolder dataBuffer, root: RenameDataFolder root:dataBuffer, $NewFold SetDataFolder FoldPath string list = WaveList("Record*",";","")// Save the list of waves // SaveData /D=1 /J=list /P=DataPath /Q /T// This would have to be done with the Open and FBinWrite commands most likely. // Restore the original data folder and the board to a known configuration SetDataFolder origDF // Update all the various panels and devices CORD_UpdateRecWaves()// Update the FileCnt variable now that the data has been transferred and stored FileCnt += 1 NVAR SweepNum = root:DAQ:General:SweepNum SweepNum = 0 SVAR display_sweep = root:DAQ:General:curr_sweep display_sweep = num2str(SweepNum+1)// Run online analysis?//-----------------------// Outline:// plot the last acquired data// load the module that is associated with the protocol// run the analysis// somehow reinitialize so that recordings could continue normally//----------------------- print "Executed SaveRecordBinary"End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_UpdateRecWaves()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// WAVE/T recWaves = root:DAQ:General:recWaves variable AllFolders = CountObjects("root:",4) string tmp1 = "", thisDF = GetDataFolder(1) NVAR FileCnt = root:DAQ:General:FileCnt SetDataFolder root:// Reset the Listbox text wave in the event that some folders have been deleted recWaves = {"none"} variable index=0, count=0 string ShortName1 = "", ShortName2 = "", previousName = "", ShortNameMid="" do if (index > AllFolders) break endif tmp1= GetIndexedObjName("root:",4,index) if(stringmatch(tmp1,"f*")) // Parse the name of the folder ShortName1 = StringFromList(0,tmp1,"_") ShortName2 = StringFromList(1,tmp1,"_")// ShortName2 = StringFromList(2,tmp1,"_") // Make sure the numbering is in order if( !((str2num(ShortName2)) == (str2num(previousName)+1)) && (strlen(previousName)>0) ) ShortName2 = num2str( (str2num(previousName)+1) )// RenameDataFolder $tmp1, $(ShortName1+"_"+ShortNameMid+"_"+ShortName2) RenameDataFolder $tmp1, $(ShortName1+"_"+ShortName2) endif // Update the text wave list recWaves[count] = {ShortName1+"_"+ShortName2} // Update the counter to make the text wave contiguous count+=1 // Keep track of the name from the last loop previousName = ShortName2 endif index+=1 while(1)// Need to test for the case of erasing all waves back to zero if( stringmatch(recWaves[0],"none") || !(FileCnt>0) ) FileCnt = 0 endif SetDataFolder thisDF ControlUpdate/A /W=CORD_MainPanelEnd // UpdateRecWaves/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_PulseControl(cntrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string cntrlName CORD_CreateTestPulsePanel() End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_MakeChanConfigPanel()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DoWindow/F CORD_ChanConfig if (V_Flag!=0) return 0 endif Execute "CORD_ChanConfig()" Execute "ModifyPanel cbRGB = (32125,33410,39321)"End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_SetChan(cntrlName,popNum,popStr) : PopupMenuControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string cntrlName variable popNum string popStr variable/G root:DAQ:Classes:Displays:totalchan = str2num(popStr) CORD_DisplayChannels() variable tmp = str2num(popStr) if(tmp>4) Variable/G root:DAQ:General:averaging = 0 // 30kHz for 8 channels does not allow AVG=5 else Variable/G root:DAQ:General:averaging = 1 endif End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_MakeCC(cntrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string cntrlName CORD_MakeChanConfigPanel()End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_KillCC(cntrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string cntrlName DoWindow/K CORD_ChanConfigEnd //CORD_KillCC/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_CreateAmpObj(type, chanName)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string type, chanName string origDF = GetDataFolder(1) SetDataFolder root:DAQ:General: SVAR currChan = $chanName if(SVAR_exists(currChan) == 0) string/G $chanName SVAR currChan = $chanName endif currChan = type SetDataFolder origDFEnd///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_LaunchGeneralStringDialog(title,defvalue)/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string title string defvalue String thisDF = GetDataFolder(1) SetDataFolder root:DAQ:General string/G GeneralStringDialog_title = title string/G GeneralStringDialog_value = defvalue SetDataFolder thisDF Execute "CORD_GeneralStringDialog()" PauseForUser CORD_GeneralStringDialog SetDataFolder thisDFEnd/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_InitializeAmpClasses()/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////string thisDF = GetDataFolder(1) SVAR AmpPreset = root:ExpDetails:AmpPreset NewDataFolder/O root:DAQ NewDataFolder/O root:DAQ:Classes NewDataFolder/O/S root:DAQ:Classes:Amplifiers variable/G root:DAQ:Classes:Amplifiers:Channel_A_scaling string/G root:DAQ:Classes:Amplifiers:Channel_A_mode Make/O/N=4 root:DAQ:Classes:Amplifiers:Channel_A_gains = {1000/2.5,1000/50,1/20,1/400} // set to default in case update does not occur before needed for use because i set the output values in the protocol generator which may or may not have run telegraph enough times to have correct gains. variable/G root:DAQ:Classes:Amplifiers:Channel_A_lpf variable/G root:DAQ:Classes:Amplifiers:Channel_A_Cm variable/G root:DAQ:Classes:Amplifiers:Channel_A_Rs variable/G root:DAQ:Classes:Amplifiers:Channel_B_scaling string/G root:DAQ:Classes:Amplifiers:Channel_B_mode Make/O/N=4 root:DAQ:Classes:Amplifiers:Channel_B_gains = {1000/2.5,1000/50,1/20,1/400} variable/G root:DAQ:Classes:Amplifiers:Channel_B_lpf variable/G root:DAQ:Classes:Amplifiers:Channel_B_Cm variable/G root:DAQ:Classes:Amplifiers:Channel_B_Rs// This should now be in the ELN section, but default to a multiclamp? Comment this line out if you have problems CORD_ReadAmpState("Multiclamp700B",1)SetDataFolder thisDFEnd // InitializeAmpClasses/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Structure AxonTelegraph_DataStruct uint32 Version // Structure version. Value should always be 13. uint32 SerialNum uint32 ChannelID uint32 ComPortID uint32 AxoBusID uint32 OperatingMode String OperatingModeString uint32 ScaledOutSignal String ScaledOutSignalString double Alpha double ScaleFactor uint32 ScaleFactorUnits String ScaleFactorUnitsString double LPFCutoff double MembraneCap double ExtCmdSens uint32 RawOutSignal String RawOutSignalString double RawScaleFactor uint32 RawScaleFactorUnits String RawScaleFactorUnitsString uint32 HardwareType String HardwareTypeString double SecondaryAlpha double SecondaryLPFCutoff double SeriesResistanceEndStructure///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_ReadAmpState(ampType,initialize)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Retrieve telegraph data from the amplifier; rev. March 2010 to use the supplied Igor multiclamp telegraphing information////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string ampType // if this is a multiclamp good to go. if it is something else user is required to implement variable initialize // if this has not been called before, get some necessary codes string thisDF = GetDataFolder(1) strswitch(ampType) case "Multiclamp700B": // Make sure communication with the amplifier is intact if(initialize) SetDataFolder root:DAQ:Classes:Amplifiers AxonTelegraphFindServers /Z=1 if(V_flag==0) WAVE amp_response = W_TelegraphServers Duplicate/O amp_response, MulticlampServerInfo print "Using Multiclamp Amplifier; Serial Number: "+num2istr(amp_response[0][0])+". Storing data about the telegraph server in root:DAQ:Classes:Amplifiers:MulticlampServerInfo" variable/G root:DAQ:Classes:Amplifiers:telLogic = 1 else variable/G root:DAQ:Classes:Amplifiers:telLogic = 0 Abort "Cannot find a connected Multiclamp. Either turn it on or select a different amplifier from the pulldown menu." endif // Set some variable to indicate telegraphing in working AxonTelegraphSetTimeoutMs(1000) endif // Get the current state of the amplifier WAVE MulticlampServerInfo = root:DAQ:Classes:Amplifiers:MulticlampServerInfo variable channel_num=1 string channel="", channels = "A;B" string ref = "" STRUCT AxonTelegraph_DataStruct tds tds.Version = 13 for(channel_num=1;channel_num<=2;channel_num+=1) channel = StringFromList(channel_num-1,channels) AxonTelegraphGetDataStruct(MulticlampServerInfo[0][0], channel_num, 1, tds) ref = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_mode" SVAR mode = $ref mode = tds.OperatingModeString //print mode ref = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_scaling" NVAR scaling = $ref scaling = tds.ScaleFactor * tds.Alpha //print scaling strswitch(mode) case "V-Clamp": ref = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_gains" WAVE gains = $ref gains[0] = 1000/scaling gains[2] = tds.ExtCmdSens //print tds.ExtCmdSens break case "I-Clamp": ref = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_gains" WAVE gains = $ref gains[1] = 1000/scaling gains[3] = tds.ExtCmdSens //print tds.ExtCmdSens break endswitch ref = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_lpf" NVAR filter = $ref filter = tds.LPFCutoff //print filter ref = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_Cm" NVAR cm = $ref cm = tds.MembraneCap //print cm ref = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_Rs" NVAR rs = $ref rs = tds.SeriesResistance //print rs endfor break endswitch CORD_UpdateELNdata(1) SetDataFolder thisDFend/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_KillGeneralStringDialog(ctrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string ctrlName DoWindow/K CORD_GeneralStringDialogEnd/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BEGIN THE WINDOW DESCRIPTION HERE/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Window CORD_MainPanel() : Panel PauseUpdate; Silent 1 variable dispX = str2num(StringFromList(3, StringByKey("SCREEN1", IgorInfo(0)),",")) variable dispY = str2num(StringFromList(4, StringByKey("SCREEN1", IgorInfo(0)),",")) NewPanel/W=(10,0,185,420)/K=1 as "Main" SetDrawLayer ProgBack Print "Main DAQ panel launched at "+time()+" on "+date() SetDrawLayer UserBack// Main buttons to acquire data variable ButtonOffset = 10 Button MainButton1,pos={11,ButtonOffset},font="Verdana",size={30,30}, proc=CORD_ACQ_main, title=">", help={"Press to acquire without recording"} Button MainButton2,pos={52,ButtonOffset},font="Verdana",size={30,30}, proc=CORD_ACQ_main, title="O", help={"Press to execute protocol and record acquired data"} Button MainButton3,pos={93,ButtonOffset},font="Verdana",size={30,30}, proc=CORD_ACQ_main, title="||", help={"Press to stop acquiring/recording"}// Button MainButton4,pos={134,78},font="Verdana",size={30,25}, proc=CORD_ACQ_main, title="~O", help={"Press to overwrite last file with new recording"} Button StepButton1,pos={134,ButtonOffset},font="Verdana",fsize=10,size={30,30}, proc=CORD_PulseControl, title="TP" // Active protocol displayGroupBox CurrentProtocolGroup,pos={6,45},size={163,153},font="Verdana",title="Active Protocol",fColor=(60000,20000,40000),fstyle=0,fsize=11,labelBack=(60000,20000,40000)// Use ControlUpdate/A within the load function to update control panel SetVariable ActiveProt1,pos={10,63},size={153,20},title="Name:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:gactiveprot,noedit=1 SetVariable ActiveProt2,pos={10,86},size={71,20},title="AD:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:gactivechanIn,noedit=1 SetVariable ActiveProt2a,pos={92,86},size={71,20},title="DA:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:gactivechanOut,noedit=1 SetVariable ActiveFile1,pos={10,109},size={153,20},title="DF:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:gactivefile,noedit=1 SetVariable ActiveProt4,pos={10,132},size={153,20},title="Analysis:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:associatedmod,noedit=1 SetVariable ActiveProt3a,pos={10,155},size={81,20},title="Sweep:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:curr_sweep,noedit=1 SetVariable ActiveProt3,pos={102,155},size={61,20},title="of",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:gactivesweeps,noedit=1 SetVariable ActiveProt5,pos={10,178},size={81,20},title="Sample:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:SampleRate,noedit=1 SetVariable ActiveProt6,pos={102,178},size={61,20},title="Avg:",font="Verdana",fsize=10,limits={-Inf,Inf,0},value=root:DAQ:General:averaging,noedit=1 // Controls for acquired data displaysGroupBox DisplayGroup,pos={6,203},size={163,180},font="Verdana",title="Data Display",fColor=(20000,40000,60000),fstyle=0,fsize=11,labelBack=(20000,40000,60000) Button DisplayButton1,pos={11,223},font="Verdana",fsize=10,size={35,20}, proc=CORD_DisplayControl, title="Last" Button DisplayButton2,pos={50,223},font="Verdana",fsize=10,size={35,20}, proc=CORD_DisplayControl, title="Sel." Button DisplayButton3,pos={88,223},font="Verdana",fsize=10,size={35,20}, proc=CORD_DisplayControl, title="Del." Button DisplayButton4,pos={126,223},font="Verdana",fsize=10,size={35,20}, proc=CORD_DisplayControl, title="Anl." ListBox DisplayList1,frame=1,fsize=10,listWave=root:DAQ:General:recWaves,mode=1,pos={11,248},size={152,125} PopupMenu DefChan,bodyWidth=60,font="Verdana", proc=CORD_SetChan,pos={63,392},title="Chans:",value="2;4;8;1",fsize=10// Kind of ugly way to activate the GUSstageCheckBox GusBox,disable=0,mode=0, proc=CORD_GUSstage,pos={125,395},title="GUS",value=0, font="Verdana", fsize=10ResumeUpdateEndMacro/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Window CORD_ChanConfig() : Panel///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// PauseUpdate; Silent 1 // building the window... variable dispX = str2num(StringFromList(3, StringByKey("SCREEN1", IgorInfo(0)),",")) variable dispY = str2num(StringFromList(4, StringByKey("SCREEN1", IgorInfo(0)),",")) NewPanel/W=(dispX-312,0,dispX-12,250)/K=1 as "Channel Configuration"// Error message TitleBox CC_Details font="Arial", frame=0, fsize=12, fstyle=1, pos={10,50}, size={200,20},title="Currently the channel settings are predefined as:" TitleBox CC_Details2 font="Arial", frame=0, fsize=12, fstyle=1, pos={10,70}, size={200,20},title="Channel_A=AD0, Channel_B=AD1, and so on" TitleBox CC_Details3 font="Arial", frame=0, fsize=12, fstyle=1, pos={10,90}, size={200,20},title="Future releases will support more flexibility."// Amp settings TitleBox CC_Details4 font="Arial", frame=0, fsize=12, fstyle=1, pos={10,130}, size={200,20},title="Set amplifiers from pull down menus below" PopupMenu CC_Set_Channel_A bodyWidth=100, font="Arial", fsize=12, fstyle=1, proc=CORD_SetChan,pos={130,155},title="Channel_A ::",value="None;Multiclamp700B;Multiclamp700B_S", popvalue=root:DAQ:General:Channel_A, mode=1 PopupMenu CC_Set_Channel_B bodyWidth=100, font="Arial", fsize=12, fstyle=1, proc=CORD_SetChan,pos={130,180},title="Channel_B ::",value="None;Multiclamp700B;Multiclamp700B_S", popvalue=root:DAQ:General:Channel_B, mode=1 PopupMenu CC_Set_Channel_C bodyWidth=100, font="Arial", fsize=12, fstyle=1, proc=CORD_SetChan,pos={310,155},title="Channel_C ::",value="None;Multiclamp700B;Multiclamp700B_S", popvalue=root:DAQ:General:Channel_C, mode=1 PopupMenu CC_Set_Channel_D bodyWidth=100, font="Arial", fsize=12, fstyle=1, proc=CORD_SetChan,pos={310,180},title="Channel_D ::",value="None;Multiclamp700B;Multiclamp700B_S", popvalue=root:DAQ:General:Channel_D, mode=1// Kill button Button CC_Kill title="Close",pos={150,215},size={100,20},proc=CORD_KillCCEndMacro///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Window CORD_GeneralStringDialog() : Panel/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// PauseUpdate; Silent 1 NewPanel/W=(400,340,700,440)/K=1 as root:DAQ:General:GeneralStringDialog_title SetVariable ModuleNameSetVar bodywidth=200,noproc,pos={240,10},title="Name :: ",value=root:DAQ:General:GeneralStringDialog_value Button KillButton, pos={110,70}, size={80,20}, proc=CORD_KillGeneralStringDialog, title="Close"End///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_GUSstage(ctrlName,checked) : CheckBoxControl////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// String ctrlName Variable checked switch(checked) case 1: print "Activate Port0.0 and Port0.6 for use of the GUSstage 16 channel headstage" DAQmx_DIO_Config /DEV="Dev1" /DIR=1 /LGRP=1 "/Dev1/port0/line0,/Dev1/port0/line6" variable/G root:DAQ:General:GUSindex = V_DAQmx_DIO_TaskNumber NVAR GUSindex = root:DAQ:General:GUSindex fDAQmx_DIO_Write("Dev1",GUSindex, 1) break case 0: print "Restore low logic to all ports for normal recordings" NVAR GUSindex = root:DAQ:General:GUSindex fDAQmx_DIO_Write("Dev1",GUSindex, 0) fDAQmx_DIO_Finished("Dev1", GUSindex) break endswitch End///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////function CORD_MakeRescaleWindow()/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// variable/G root:DAQ:General:rescale = 0 variable/G root:DAQ:General:OnlineScaleFactor = 1 DoWindow/F CORD_RescalePanel if (V_Flag!=0) DoWindow/K CORD_RescalePanel endif Execute "CORD_RescalePanel()" Execute "ModifyPanel cbRGB = (20000,20000,20000)"End///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Window CORD_RescalePanel() : Panel/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// PauseUpdate; Silent 1 // building the window... NewPanel/W=(10,685,185,735)/K=1 as "Scaling" SetDrawLayer UserBack SetDrawEnv fstyle=2 CheckBox ReScaleOn,disable=0,mode=0, proc=CORD_RescalePanelToggle,pos={10,20},title="Rescale?",value=0, font="Verdana", fsize=10 SetVariable ScaleVar bodyWidth=40, frame=1, fsize=11, limits={0,inf,0}, pos={110,18}, noproc, value=root:DAQ:General:OnlineScaleFactor, title="factor"End//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_RescalePanelToggle(ctrlName,checked) : CheckBoxControl////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// String ctrlName Variable checked NVAR rescale = root:DAQ:General:rescale NVAR OnlineScaleFactor = root:DAQ:General:OnlineScaleFactor rescale = checked switch(checked) case 1: print "Protocol outputs will be multiplied by "+num2str(OnlineScaleFactor) break case 0: print "Protocols will use original scaling" break endswitchend////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DEPRECATED FUNCTIONS//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_ReadAmpState(ampType,initialize)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Retrieve telegraph data from the amplifier//// rev March 2010 to use the supplied Igor multiclamp telegraphing information////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string ampType // if this is a multiclamp good to go. if it is something else user is required to implement// variable initialize // if this has not been called before, get some necessary codes// //// Define the correct path to the telegraph output// PathInfo/S AmpPath// if(V_flag==0)//// Abort "Telegraphing is only supported on windows machines; Please turn off in the main DAQ panel; If you are running a windows machine and getting this message please check CORDUROY_ANALYSIS_personal to set this path correctly."// variable/G root:DAQ:Classes:Amplifiers:TelLogic = 0 // else// variable/G root:DAQ:Classes:Amplifiers:TelLogic = 1// endif// //// convert channel to a number// variable chan// if(stringmatch(channel,"A"))// chan = 1// else// chan = 2// endif////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Need to modify to work with Multiclamp Console program//// First, have to command line call the program to create telegraph output//// Next, read and parse the file with somewhat different commands than previously//// Finally, update all settings...////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// use the amp serial number and the path to the telegraphed txt file// SVAR SerialNumber = root:DAQ:Classes:Amplifiers:SerialNumber// string File2Load = SerialNumber+"_"+num2str(chan)+".txt"//// print File2Load// //// Load and read the telegraph file // string/G Mode, telFile// variable/G Primary_Scale_Factor, Primary_Scale_Factor_Units, Primary_Gain, Scale_Factor, refNum, len// // Open /P=AmpPath /R refNum as File2Load//// do// FReadLine refNum, telFile// len = strlen(telFile)// if (len == 0)// break // No more lines to be read// endif//// // Get various parameters from the metadata// if(stringmatch(telFile, "Mode*"))// sscanf telFile, "Mode: %s", Mode// endif//// if(stringmatch(telFile, "Primary_Scale_Factor:*"))// sscanf telFile, "Primary_Scale_Factor: %e", Primary_Scale_Factor// endif//// if(stringmatch(telFile, "Primary_Scale_Factor_Units*"))// sscanf telFile, "Primary_Scale_Factor_Units: %f", Primary_Scale_Factor_Units// endif// // if(stringmatch(telFile, "Primary_Gain*"))// sscanf telFile, "Primary_Gain: %f", Primary_Gain// endif// // while (1)//// Close refNum// // //always plot the result in terms of pA for voltage clamp and mV for current clamp// if(stringmatch(Mode,"V-Clamp"))// Scale_Factor = Primary_Scale_Factor * Primary_Gain * (1000^(Primary_Scale_Factor_Units-6)) / 1000// else// Scale_Factor = Primary_Scale_Factor * Primary_Gain * (1000^(Primary_Scale_Factor_Units)) / 1000// endif// // //Update the global amp variable with the necessary information// string ChanRef_Scale = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_scaling"// string ChanRef_Mode = "root:DAQ:Classes:Amplifiers:Channel_"+channel+"_mode"//// NVAR local_scale = $ChanRef_Scale// SVAR local_mode = $ChanRef_Mode// // print Scale_Factor// local_scale = Scale_Factor// local_mode = Mode// //end