Commits

hardwood committed f3004ac

Local changes

  • Participants
  • Parent commits 5afbb65

Comments (0)

Files changed (3)

File Acquisition/Acquisition Wave Functions.ipf

 	string daq=Chan2DAQ(chan)
 	string win=DAQ+"_Selector"
 	Core#SetStrPackageSetting(module,"stimuli",GetChanName(chan),"assembler",assembler)
+	string ampl_title="Ampl"
+	string dAmpl_title="\F'Symbol'D\F'Default'Ampl"
 	strswitch(assembler)
+		case "Ramp":
+			ampl_title="Min"
+			dAmpl_title="Max"
+			break
+		case "Sine":
+			dAmpl_title="Freq"
+			break
 		case "Noisy":
-			string title="StDev"
+			dAmpl_title="StDev"
 			break
 		case "Frozen":
 		case "FrozenPlusNegative":
-			title="Multiplier"
+			dAmpl_title="Multiplier"
 			dfref df=Core#InstanceHome(module,"stimuli",GetChanName(chan))
 			wave /z/sdfr=df Frozen
 			if(!waveexists(Frozen))
 		case "Optimus2":
 			SweepIndexWindow()
 		default:
-			title="\F'Symbol'D\F'Default'Ampl"
+			//ampl_title="Ampl"
+			//dAmpl_title="\F'Symbol'D\F'Default'Ampl"
 			break
 	endswitch
-	Titlebox Title_dAmpl title=title, win=$win
+	Titlebox Title_ampl title=ampl_title, win=$win
+	Titlebox Title_dAmpl title=dAmpl_title, win=$win
 end
 
 function SetListenHook(hook[,DAQ])
 	return dAmpl
 end
 
-function GetLivePulseSets(chan[,sweepNum])
+function /wave GetLivePulseSets(chan[,sweepNum])
 	variable chan,sweepNum
 	
 	wave divisor = GetChanDivisor(chan,sweepNum=sweepNum)
 	wave remainder = GetChanRemainder(chan,sweepNum=sweepNum)
 	make /free/n=(numpnts(divisor)) pulseSetState = 2^mod(divisor[p],sweepNum) & remainder[p]
+	if(numpnts(divisor)==1)
+		pulseSetState = 1
+	endif
 	extract /free/indx pulseSetState,livePulseSets,pulseSetState>0
 	return livePulseSets
 end
 	wave Stimulus
 	variable chan,firstSample,lastSample,pulseNum,pulseSet,sweepParity
 	
-	variable begin=GetStimParam("Begin",chan,pulseSet)		//Begin time
-	variable width=GetStimParam("Width",chan,pulseSet)		//Set frequency (Hz)
+	variable freq=GetStimParam("dAmpl",chan,pulseSet)		//Set frequency (Hz)
 	variable ampl=GetStimParam("Ampl",chan,pulseSet)		//Set amplitude
+	variable kHz=GetKHz(MasterDAQ())
+	variable start = firstSample/(1000*kHz)
 	
-	make/o/n=10000 SineWave
-	setscale x,0,1,SineWave  
-	SineWave = Ampl * sin(2*pi*x*width)
-	
-	save SineWave
-	
-	display SineWave
-	
-//From duplicated code- probably don't need
-//	variable ampl=GetStimParam("Ampl",chan,pulseSet)
-
-//	variable width=lastSample-firstSample
-//	variable start=abs(enoise(dimsize(Stimulus,0)))
-//	Stimulus[start,start+width][sweepParity][pulseSet]+=ampl+dampl*pulseNum
-//	variable pulses=GetStimParam("Pulses",chan,pulseSet)
-//	if(pulseNum==pulses-1)
-//		Convolve AlphaSynapso(1,3,0,50),Stimulus
-//	endif
+	Stimulus[firstSample,lastSample][sweepParity][pulseSet]+= ampl * sin(2*pi*(x-start)*freq)
 end
 
+//sin function added by AG 3-21-13
+function Ramp_stim(Stimulus,chan,firstSample,lastSample,pulseNum,pulseSet,sweepParity)
+	wave Stimulus
+	variable chan,firstSample,lastSample,pulseNum,pulseSet,sweepParity
+	
+	variable amplEnd=GetStimParam("dAmpl",chan,pulseSet)		//Set frequency (Hz)
+	variable amplStart=GetStimParam("Ampl",chan,pulseSet)		//Set amplitude
+	variable kHz=GetKHz(MasterDAQ())
+	variable start = firstSample/(1000*kHz)
+	variable width = (lastSample-firstSample+1)/(1000*kHz)
+	variable slope = (amplEnd-amplStart)/width
+	
+	Stimulus[firstSample,lastSample][sweepParity][pulseSet]+= amplStart + slope*(x-start)
+end
 
+#ifndef Aryn
 function Optimus1_stim(Stimulus,chan,firstSample,lastSample,pulseNum,pulseSet,sweepParity)
 	wave Stimulus
 	variable chan,firstSample,lastSample,pulseNum,pulseSet,sweepParity
 	save /p=desktop sharedE as stimName+"_sharedE_"+Timestamp()+".ibw"
 	save /p=desktop sharedI as stimName+"_sharedI_"+Timestamp()+".ibw"
 end
+#ifndef Aryn
 
 function /s AssemblerNames(name)
 	string name

File Acquisition/Acquisition.ipf

 #ifdef Rick
 	//ISI=10+floor(abs(enoise(10)))
 #endif
+#ifdef Aryn
+	//printf "We injected %d pA\r",GetCurrent()
+#endif
 	//endif
 End
 

File Users/Aryn.ipf

 #pragma rtGlobals=1		// Use modern global access method.
 
-//
-//#ifdef Acq
-//#include "Spike Functions"
-//#endif
-
-//function StimulusTable()
+#ifdef Acq
+#include "Spike Functions"
+#endif
+#include "Waves Average"
+
+override function MakeLogPanel()
+        if(WinType("LogPanel"))
+                DoWindow /F LogPanel
+                return 0
+        else
+                NewNotebook/W=(600,570,940,710) /F=0/N=LogPanel
+        endif
+        end
+        
+      
+
+
+
+function StimulusTable()
 	dowindow /k StimTable
-	edit /k=1/n=StimTable.ld as "Stimulus Table"
+	edit /k=1/n=StimTable as "Stimulus Table"
 	variable num_channels = GetNumChannels() // Number of channels.  
 	variable curr_sweep = GetCurrSweep() // Current sweep number.  
 	make /o/n=(curr_sweep,num_channels) StimulusAmplitudes
-	variable i
+	variable i,j,k
 	// This part could be done in one line except for the labeling of the table.  
 	for(i=0;i<curr_sweep;i+=1)
 		setdimlabel 0,i,$("Sweep "+num2str(i)) StimulusAmplitudes
 		for(j=0;j<num_channels;j+=1)
 			setdimlabel 1,j,$GetChanLabel(j) StimulusAmplitudes
 			wave ampl = GetAmpl(j,sweepNum=i)
-			wave livePulseSets = GetLivePulseSets(j,i)
+			wave livePulseSets = GetLivePulseSets(j,sweepNum=i)
 			variable result = 0
 			for(k=0;k<numpnts(livePulseSets);k+=1)
 				result += ampl[livePulseSets[k]]
 			StimulusAmplitudes[i][j] = result
 		endfor
 	endfor
-	append StimulusAmplitudes
-end
+	make /o/n=(curr_sweep) StimulusAmpls_0 = StimulusAmplitudes[p][0]
+	make /o/n=(curr_sweep) StimulusAmpls_1 = StimulusAmplitudes[p][1]
+	appendtotable StimulusAmpls_0//,StimulusAmpls_1
+end
+
+
+
+#pragma rtGlobals=1		// Use modern global access method.
+
+//This procedure file keeps track of all custom preferences.  In general, these preferences are 
+//user entered parameters in dialog boxes.  Managing preferences this way causes dialog box
+//values to be preserved, even when Igor is turned off.  See the Igor manual for more information
+//on LoadPackagePreferences, SavePackagePreferences etc.
+
+	static StrConstant kPackageName = "Salk SNL-D Igor Package"
+	static StrConstant kPreferencesFileName = "Salk SNL-D Custom Igor Prefs"
+	static constant MAX_STRING =100  //This should be 128 to match the data file.  Igor 5.05A does not allow structures with arrays of length > 100.  BAD IGOR.  BAAAAD IGOR.
+	static constant MAX_SEGMENTS = 4
+	
+	//Amplifier settings
+	constant NONE = 0;
+	constant AXOCLAMP2B = 1;
+ 	constant AXOPATCH200B = 2;
+	constant MULTICLAMP = 3;
+
+	
+	//Acquisition Tags
+	static constant AMPLIFIER_TAG = 0
+//	static constant SPONTANEOUS_TAG = 1
+//	static constant INPUTRESISTANCE_TAG = 3
+//	static constant TESTPULSE_TAG = 4
+	//	static constant SINERUN_TAG = 5 //Number changed to 10
+//	static constant VCSTEPRUN_TAG=6
+	//	static constant VCMULTIPULSE_TAG=7 //Numbers changed to 40-49
+	static constant SPIKESTIM_TAG = 8
+//	static constant SETTINGSNUMBER_TAG = 9
+	static constant SINERUN_TAG = 10
+	//	static constant NA_INACTIVATION_TAG = 11 //Numbers changed to 50-59
+	//	static constant NA_Slow_INACT_TAG = 12 //Numbers changed to 60-69
+	
+	//	static constant STIM_TAG =13  //Deprecated 
+	//	static constant STIMALTERNATE_TAG = 14 //Deprecated
+	//	static constant RAMANSTIM_TAG = 15 //Deprecated
+
+	//static constant RAMP_TAG = 16
+//	static constant NA_SPIKE_INACT_TAG = 17  //Deprecated
+	static constant NA_SPIKE_INACT_TAG = 18
+	static constant SETTINGSNUMBER_TAG = 19
+
+
+	
+//	static constant FIRST_ISOLATOR_STIM_TAG = 20//  20-29 RESERVED  Numbers changed to 80-89
+	
+	static constant FIRST_STEPRUN_TAG = 30  //30-39 RESERVED
+	
+	static constant VCMULTIPULSE_TAG=40 //40-49 RESERVED
+	
+	static constant NA_INACTIVATION_TAG = 50 //50-59 RESERVED
+	static constant NA_Slow_INACT_TAG = 60 //60-69 RESERVED
+	static constant NA_INACT_VOLTAGE_TAG = 70 //70-79 RESERVED
+	
+//	static constant ISOLATOR_STIM_TAG = 80//  80-99 RESERVED, 10 for acquisition, 10 for analysis
+	
+	static constant PULSE_TRAIN_TAG = 100 //100-109 RESERVED
+	
+//	static constant ISOLATOR_STIM_TAG = 110//  110-129 RESERVED, 10 for acquisition, 10 for analysis
+	
+	static constant TESTPULSE_TAG = 130
+	static constant VCSTEPRUN_TAG= 131
+	static constant INPUTRESISTANCE_TAG = 132
+	//static constant OPTICAL_STIM_TAG = 133
+	static constant OPTICAL_STIM_TAG = 134
+	static constant MULTICLAMP_TAG = 135
+	
+	static constant ISOLATOR_STIM_TAG = 140//  140-159 RESERVED, 10 for acquisition, 10 for analysis
+	static constant ISO_SIN_STIM_TAG = 160 //160 - 169 RESERVED
+	
+	static constant RAMPVC_TAG = 171
+	static constant RAMPCC_TAG = 172
+	static constant SPONTANEOUS_TAG = 173
+	static constant WHITENOISE_TAG = 174
+	
+		
+	static constant MULTICHAN_TAG = 180  //180-189
+	
+	static constant MCLEVELS_TAG = 190 //190-209
+	
+	static constant MCISOSTIM_TAG = 210 //210-219
+	
+	static constant MCWAVEFORM_TAG = 220 //220-239
+	
+		static constant MCISOSTIM_FILE_TAG = 240 //240-240
+
+	
+
+	//Analysis Tags
+	//static constant IFPLOT_TAG = 1001 changed to 1009
+	static constant RIN_TAG = 1002
+	//	static constant SPIKEPARAMS_TAG = 1003  changed to 1007
+	static constant MEANRATE_TAG = 1004
+	//static constant STEPRESPONSES_TAG = 1005
+	//	static constant VC_STEP_RUN_PLOT_TAG = 1006 changed to 1008
+//	static constant SPIKE_PARAMS_TAG = 1007
+	static constant VC_STEP_RUN_PLOT_TAG = 1008
+	//static constant IFPLOT_TAG = 1009
+	//static constant IFPLOT_TAG = 1010
+	//static constant SINE_FIT_TAG = 1011
+	static constant SPIKE_CODE_TAG = 1012
+	//static constant SINE_FIT_TAG = 1013
+	static constant APPEND_GRAPH_TAG = 1014
+	static constant SPIKE_PARAMS_TAG = 1015
+	static constant RIN_FIT_TAG = 1016
+	static constant SPONT_PARAMS_TAG = 1017
+	//static constant IFPLOT_TAG = 1018
+	//static constant IFPLOT_TAG = 1019
+	static constant AUTOSAVE_TAG = 1020
+	static constant MUTLI_TABLES_TAG = 1021
+	static constant VIEWER_TAG = 1030 //1030-1039 reserved
+	static constant PARAMS_BY_SPIKE_TAG = 1040
+	static constant IFPLOT_TAG = 1042
+	//static constant WHITE_ANALY_TAG = 1043
+	static constant WHITE_MODEL_TAG = 1044
+	static constant SINE_FIT_TAG = 1045
+	static constant WHITE_ANALY_TAG = 1046
+	
+	
+	
+	Structure AutoSavePreferences	
+		uint32 autosave
+	EndStructure
+
+Function LoadAutoSavePreferences(prefs)
+	STRUCT AutoSavePreferences &prefs
+	Variable kPreferencesRecordID = AUTOSAVE_TAG  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 )
+
+		prefs.autosave = 1;
+
+	endif
+End
+
+
+Function SetAutoSavePreferences(prefs)
+	STRUCT AutoSavePreferences &prefs
+	Variable kPreferencesRecordID = AUTOSAVE_TAG 
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+	Structure AmplifierPreferences
+	uint32 version  //Currently 100, increment each time the structure is changed.
+	uint32 amplifier
+	uint16 reserved[100] //Reserved for future options.
+	EndStructure
+
+Function LoadAmplifierPreferences(prefs)
+	STRUCT AmplifierPreferences &prefs
+	Variable kPreferencesRecordID = AMPLIFIER_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+	
+		prefs.version = currentPrefsVersion
+		
+		prefs.amplifier = MULTICLAMP;
+
+		Variable i
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+//Use when setting programmatically
+Function SetAmplifierPreferences(prefs)
+	STRUCT AmplifierPreferences &prefs
+	Variable kPreferencesRecordID = AMPLIFIER_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//Use when setting with the user interface.
+Function SetAmplifierPrompt()
+	STRUCT AmplifierPreferences prefs
+	LoadAmplifierPreferences(prefs)
+	Variable amplifier = prefs.amplifier
+	
+	//String amplifier = ""
+
+	prompt  amplifier "Amplifier (0: None, 1: Axoclamp2B, 2:Axopatch200B, 3:Multiclamp)"//popup "None;Axoclamp2B;Axopatch200B;Multiclamp"
+
+	DoPrompt "Choose Amplifier", amplifier
+	If(V_flag)
+		abort
+	endif
+	
+	prefs.amplifier = amplifier
+
+	SetAmplifierPreferences(prefs)
+	
+	KillWaves/A/Z
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure MulticlampPreferences
+double vcFeedback[4]
+double vcCommand[4]
+double ccFeedback[4]
+double ccCommand[4]
+
+EndStructure
+
+Function LoadMultiClampPreferences(prefs)
+	STRUCT MultiClampPreferences &prefs
+	Variable kPreferencesRecordID = MULTICLAMP_TAG  //Increment for each new record type
+	
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		Variable i
+		for(i=0; i<4; i+=1)	
+			prefs.vcFeedback[i] = 500 //MOhms
+			prefs.vcCommand[i] = 20 //mV/V
+			prefs.ccFeedback[i] = 500 //MOhms
+			prefs.ccCommand[i] = 400 //pA/V
+		endfor
+		
+	endif
+End
+
+Function SetMulticlampPreferences(prefs)
+	STRUCT MulticlampPreferences &prefs
+	Variable kPreferencesRecordID = MULTICLAMP_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//If using the multiclamp amplifier, match these settings to those of the amplifier.
+//This will assure that input and output have the correct scaling.
+Function SetMulticlampPrompt()
+	STRUCT MulticlampPreferences prefs
+	LoadMulticlampPreferences(prefs)
+	Variable vcFeedback0 = prefs.vcFeedback[0]
+	Variable vcCommand0 = prefs.vcCommand[0]
+	Variable ccFeedback0 = prefs.ccFeedback[0]
+	Variable ccCommand0 = prefs.ccCommand[0]
+	
+	Variable vcFeedback1 = prefs.vcFeedback[1]
+	Variable vcCommand1 = prefs.vcCommand[1]
+	Variable ccFeedback1 = prefs.ccFeedback[1]
+	Variable ccCommand1 = prefs.ccCommand[1]
+
+	Prompt vcFeedback0, "VC Feedback Resistor (M�):"
+	Prompt vcCommand0, "VC Command Sensitivity (mV/V):"
+	Prompt ccFeedback0, "CC Feedback Resistor (M�):"
+	Prompt ccCommand0, "CC Command Sensitivity (pA/V):"
+	
+	Prompt vcFeedback1, "VC Feedback Resistor (M�):"
+	Prompt vcCommand1, "VC Command Sensitivity (mV/V):"
+	Prompt ccFeedback1, "CC Feedback Resistor (M�):"
+	Prompt ccCommand1, "CC Command Sensitivity (pA/V):"
+	
+	DoPrompt "Multiclamp 700B Settings:", vcFeedback0, vcCommand0, ccFeedback0, ccCommand0, vcFeedback1, vcCommand1, ccFeedback1, ccCommand1
+	
+	prefs.vcFeedback[0] = vcFeedback0
+	prefs.vcCommand[0] = vcCommand0
+	prefs.ccFeedback[0] = ccFeedback0
+	prefs.ccCommand[0] = ccCommand0
+	
+		
+	prefs.vcFeedback[1] = vcFeedback1
+	prefs.vcCommand[1] = vcCommand1
+	prefs.ccFeedback[1] = ccFeedback1
+	prefs.ccCommand[1] = ccCommand1
+	
+	SetMulticlampPreferences(prefs)
+	
+	KillWaves/A/Z
+
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure SpontaneousPreferences
+
+uchar  comment[MAX_STRING]
+
+double duration  
+uint16 durationUnits
+double sampleRate  //in kHz  //No longer queried.  Forced to be 40 kHz
+uchar adcChansString[20]
+EndStructure
+
+Function LoadSpontaneousPreferences(prefs)
+	STRUCT SpontaneousPreferences &prefs
+	Variable kPreferencesRecordID = SPONTANEOUS_TAG  //Increment for each new record type
+
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.durationUnits = 0
+				
+		prefs.duration = 5000
+		prefs.sampleRate = 40		
+
+		prefs.adcChansString = "0"
+
+	endif
+End
+
+Function SetSpontaneousPreferences(prefs)
+	STRUCT SpontaneousPreferences &prefs
+	Variable kPreferencesRecordID = SPONTANEOUS_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure InputResistancePreferences
+int32 amplitude  //in pA
+uchar comment[MAX_STRING]
+uint32 nTracesToAverage
+uint16 reserved[100] 
+EndStructure
+
+Function LoadInputResistancePreferences(prefs)
+	STRUCT InputResistancePreferences &prefs
+	Variable kPreferencesRecordID = INPUTRESISTANCE_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		prefs.amplitude = -10
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.nTracesToAverage = 2
+				
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetInputResistancePreferences(prefs)
+	STRUCT InputResistancePreferences &prefs
+	Variable kPreferencesRecordID = INPUTRESISTANCE_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure TestPulsePreferences
+uchar comment[MAX_STRING]
+double pulseAmp //relative pulse amp
+double holdingPotential
+int32 rsWaveRange
+EndStructure
+
+Function LoadTestPulsePreferences(prefs)
+	STRUCT TestPulsePreferences &prefs
+	Variable kPreferencesRecordID = TESTPULSE_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)	
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.pulseAmp = -30
+		prefs.holdingPotential = -50
+		prefs.rsWaveRange = 250
+
+	endif
+End
+
+Function SetTestPulsePreferences(prefs)
+	STRUCT TestPulsePreferences &prefs
+	Variable kPreferencesRecordID = TESTPULSE_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure SineRunPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+uchar comment[MAX_STRING]
+int32 amplitude
+uchar periods[MAX_STRING]
+uchar nPeriods[MAX_STRING]
+uint16 reserved[100] 
+EndStructure
+
+Function LoadSineRunPreferences(prefs)
+	STRUCT SineRunPreferences &prefs
+	Variable kPreferencesRecordID = SINERUN_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion	
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.amplitude = 100
+		
+		prefs.periods = "500, 2000, 250, 1000, 4000"
+		prefs.nPeriods = "10, 6, 16, 6, 5"
+				
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetSineRunPreferences(prefs)
+	STRUCT SineRunPreferences &prefs
+	Variable kPreferencesRecordID = SINERUN_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure VCStepRunPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+int32 startVoltage  //in mV
+int32 stopVoltage   //in mV
+int32 stepSize  //in mV
+double interTrialInterval  //in s No longer used
+uchar  comment[MAX_STRING]
+double prePulse  //ms
+double durPulse  //ms
+double postPulse //ms
+double holding //in mV
+int32 rsWaveRange //pA //No longer used
+uint16 reserved[96] 
+
+EndStructure
+
+Function LoadVCStepRunPreferences(prefs)
+	STRUCT VCStepRunPreferences &prefs
+	Variable kPreferencesRecordID = VCSTEPRUN_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100 
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+		
+		prefs.startVoltage = -90
+		prefs.stopVoltage = -20
+		prefs.stepSize = 10
+		prefs.interTrialInterval = 2 //no longer used
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.prePulse = 100
+		prefs.durPulse = 50
+		prefs.postPulse = 100
+		prefs.holding = -50
+		
+		prefs.rsWaveRange = 250 //No longer used
+				
+		for(i=0; i<96; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetVCStepRunPreferences(prefs)
+	STRUCT VCStepRunPreferences &prefs
+	Variable kPreferencesRecordID = VCSTEPRUN_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure VCMultipulsePreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+uchar  comment[MAX_STRING]
+double rsWaveRange //in mV  //No longer used
+double firstStepDur //in ms
+double firstStepAmp //in mV
+double secondStepDur //in ms
+double secondStepAmpInit //in mV
+double secondStepAmpLimit //in mV
+double secondStepAmpInterval//in mV
+double holdPotential //in mV
+double interTrialInterval //in s.  No longer used.
+uint16 reserved[100] 
+EndStructure
+
+Function LoadVCMultipulsePreferences(prefs, settingsNumber)
+	STRUCT VCMultipulsePreferences &prefs
+	Variable settingsNumber
+	Variable kPreferencesRecordID = VCMULTIPULSE_TAG+settingsNumber  //Increment for each new record type
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.rsWaveRange = 250  //No longer used
+		prefs.firstStepDur = 500
+		prefs.firstStepAmp = -90
+		prefs.secondStepDur = 50
+		prefs.secondStepAmpInit  = -40
+		prefs.secondStepAmpLimit = 30
+		prefs.secondStepAmpInterval = 10
+		prefs.holdPotential = -50
+		prefs.interTrialInterval = 2 //No longer used
+		
+				
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetVCMultipulsePreferences(prefs, settingsNumber)
+	STRUCT VCMultipulsePreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	Variable kPreferencesRecordID = VCMULTIPULSE_TAG + settingsNumber //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure SpikeStimPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+uchar  comment[MAX_STRING]
+uchar  stimNames[MAX_STRING]
+double holdPotential //in mV
+uint16 reserved[100] 
+EndStructure
+
+Function LoadSpikeStimPreferences(prefs)
+	STRUCT SpikeStimPreferences &prefs
+	Variable kPreferencesRecordID = SPIKESTIM_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.stimNames[i] = 0
+		endfor	
+		
+		prefs.holdPotential = -50
+				
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetSpikeStimPreferences(prefs)
+	STRUCT SpikeStimPreferences &prefs
+	Variable kPreferencesRecordID = SPIKESTIM_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure IsolatorStimPreferences
+
+//Global Characterstics
+uchar  comment[MAX_STRING]
+double duration //ms
+double interTrialInterval//s
+uint32 nTrials
+
+//CC vs VC
+double ccDur //ms
+double vcDur//ms
+uint32 pulseMode  //CC=0 or VC=1
+
+double prePulse //ms
+double durPulseA //ms
+double ampPulseA //(pA for CC, mV for VC)
+double durPulseB //ms
+double ampPulseB //(pA for CC, mV for VC)
+
+
+//Output to Stimulus Isolator
+double stim1Delay //ms
+uchar pulseWidths[MAX_STRING]
+uchar interPulseIntervals[MAX_STRING]
+uchar nPulses[MAX_STRING]
+
+uint32 stim2Active
+double stim2Delay //ms
+uint32 fitFirstEpsc //0: No, 1: Yes
+double relativeRestingTime  //ms
+double relativeStartFitTime  //ms
+double relativeEndFitTime //ms
+
+EndStructure
+
+Function LoadIsolatorStimPreferences(prefs, settingsNumber, type)
+	STRUCT IsolatorStimPreferences &prefs
+	Variable settingsNumber
+	Variable type //0 for acquisition, 1 for analysis
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	if(type ==1)
+		settingsNumber +=10
+	endif
+	
+	Variable kPreferencesRecordID = ISOLATOR_STIM_TAG +  settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.duration = 5000
+		prefs.interTrialInterval = 1
+		prefs.nTrials = 1
+		
+		prefs.ccDur = 5000
+		prefs.vcDur = 0
+		prefs.pulseMode = 0
+		prefs.prePulse = 1000
+		prefs.durPulseA = 500
+		prefs.ampPulseA = -100
+		prefs.durPulseB = 500
+		prefs.ampPulseB = 100
+		
+		prefs.stim1Delay = 1000
+		prefs.pulseWidths = "2"
+		prefs.interPulseIntervals = "6"
+		prefs.nPulses = "50"
+		prefs.stim2Active = 0
+		prefs.stim2delay = 1002
+		
+		prefs.fitFirstEpsc = 1
+		prefs.relativeRestingTime = -3
+		prefs.relativeStartFitTime = 1
+		prefs.relativeEndFitTime = 5
+
+	endif
+End
+
+Function SetIsolatorStimPreferences(prefs, settingsNumber, type)
+	STRUCT IsolatorStimPreferences &prefs
+	Variable settingsNumber
+	Variable type //0 for acquisition, 1 for analysis
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	if(type ==1)
+		settingsNumber +=10
+	endif
+	
+	Variable kPreferencesRecordID =ISOLATOR_STIM_TAG +  settingsNumber//Increment for each new record type
+
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure IsoSinStimPreferences
+
+//Global Characterstics
+uchar  comment[MAX_STRING]
+double duration //ms
+double interTrialInterval//s
+uint32 nTrials
+
+//CC vs VC
+double ccDur //ms
+double vcDur//ms
+uint32 pulseMode  //CC=0 or VC=1
+
+//Output to Stimulus Isolator
+double stim1Delay //ms
+double preSteadyStim //ms
+double modulationPeriod //ms
+double nPeriods 
+double postSteadyStim //ms
+
+double modulationOffset //Hz
+double modulationAmplitude //Hz
+double pulseWidth //ms
+
+
+uint32 stim2Active
+double stim2Delay //ms
+
+
+EndStructure
+
+Function LoadIsoSinStimPreferences(prefs, settingsNumber)
+	STRUCT IsoSinStimPreferences &prefs
+	Variable settingsNumber
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	
+	Variable kPreferencesRecordID = ISO_SIN_STIM_TAG +  settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.duration = 5000
+		prefs.interTrialInterval = 1
+		prefs.nTrials = 1
+		
+		prefs.ccDur = 5000
+		prefs.vcDur = 0
+		prefs.pulseMode = 0
+
+		
+		prefs.stim1Delay = 1000
+		prefs.preSteadyStim = 1000
+		prefs.modulationPeriod = 350
+		prefs.nPeriods = 5
+		prefs.postSteadyStim = 1000
+		prefs.modulationOffset = 50
+		prefs.modulationAmplitude = 10
+		prefs.pulseWidth = .05
+		prefs.stim2Active = 0
+		prefs.stim2delay = 1002
+		
+
+
+	endif
+End
+
+Function SetIsoSinStimPreferences(prefs, settingsNumber)
+	STRUCT IsoSinStimPreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	
+	Variable kPreferencesRecordID =ISO_SIN_STIM_TAG +  settingsNumber//Increment for each new record type
+
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure OpticalStimPreferences
+uchar  comment[MAX_STRING]
+uint32 mode
+double delay
+double interPulseInterval
+uint32 nPulses
+double gap
+uint32 nGroups
+double tail
+uint32 nTrials
+double interTrialInterval
+EndStructure
+
+Function LoadOpticalStimPreferences(prefs)
+	STRUCT OpticalStimPreferences &prefs
+	Variable kPreferencesRecordID = OPTICAL_STIM_TAG  //Increment for each new record type
+	
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.mode=0
+		prefs.delay = 500
+		prefs.interpulseInterval = 1000
+		prefs.nPulses = 2
+		prefs.gap = 2000
+		prefs.nGroups = 2
+		prefs.tail = 500
+		prefs.nTrials = 1
+		prefs.interTrialInterval = 1
+		
+	endif
+End
+
+Function SetOpticalStimPreferences(prefs)
+	STRUCT OpticalStimPreferences &prefs
+	Variable kPreferencesRecordID = OPTICAL_STIM_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure StepRunPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+int32 startCurrent  //in pA
+int32 stopCurrent   //in pA
+int32 stepSize  //in pA
+uint32 numTrials
+double interTrialInterval  //in s
+uchar  comment[MAX_STRING]
+uint32 prePulse  //ms
+uint32 durPulse  //ms
+uint32 postPulse //ms
+uint32 samplingInterval //in us  No longer used.  Fixed at 25.
+uint16 reserved[96] 
+EndStructure
+
+Function LoadStepRunPreferences(prefs, settingsNumber)
+	STRUCT StepRunPreferences &prefs
+	Variable settingsNumber
+	Variable kPreferencesRecordID = FIRST_STEPRUN_TAG+ settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+		
+		prefs.startCurrent = 0
+		prefs.stopCurrent = 200
+		prefs.stepSize = 100
+		prefs.numTrials = 1
+		prefs.interTrialInterval = 4
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.prePulse = 1000
+		prefs.durPulse = 1000
+		prefs.postPulse = 2000
+		prefs.samplingInterval = 25  //ignored.  fixed in code at 25.
+		for(i=0; i<96; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetStepRunPreferences(prefs, settingsNumber)
+	STRUCT StepRunPreferences &prefs
+	Variable settingsNumber
+	Variable kPreferencesRecordID = FIRST_STEPRUN_TAG + settingsNumber //Increment for each new record type
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure NaInactivationPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+
+uchar  comment[MAX_STRING]
+double holding  //mV
+double baseline //mV
+double pulseAmpA //mV
+double pulseAmpB //mV
+double pulseWidthA //ms
+double pulseWidthB //ms
+uchar deltaTs[MAX_STRING] //ms
+uint16 reserved[100] 
+EndStructure
+
+Function LoadNaInactivationPreferences(prefs, settingsNumber)
+	STRUCT NaInactivationPreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	Variable kPreferencesRecordID = NA_INACTIVATION_TAG + settingsNumber//Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+				
+		prefs.holding = -50
+		prefs.baseline = -50
+		prefs.pulseAmpA = 30
+		prefs.pulseAmpB = 30
+		prefs.pulseWidthA = 5
+		prefs.pulseWidthB = 5
+		prefs.deltaTs = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
+
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetNaInactivationPreferences(prefs, settingsNumber)
+	STRUCT NaInactivationPreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	Variable kPreferencesRecordID = NA_INACTIVATION_TAG + settingsNumber  //Increment for each new record type
+
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure NaSlowInactPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+
+uchar  comment[MAX_STRING]
+double holding  //mV
+double baseline //mV
+double longPulseAmp //mV
+uchar deltaTs[MAX_STRING] //ms
+double shortPulseAmp //mV
+double shortPulseWidth //ms
+
+uint16 reserved[100] 
+EndStructure
+
+Function LoadNaSlowInactPreferences(prefs, settingsNumber)
+	STRUCT NaSlowInactPreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	Variable kPreferencesRecordID = NA_Slow_INACT_TAG + settingsNumber//Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+				
+		prefs.holding = -50
+		prefs.baseline = -50
+		prefs.longPulseAmp = 30
+		prefs.deltaTs = "1,2,3,4,5,6,7,8,9,10"
+		prefs.shortPulseAmp = 30
+		prefs.shortPulseWidth = 5
+
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetNaSlowInactPreferences(prefs, settingsNumber)
+	STRUCT NaSlowInactPreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	Variable kPreferencesRecordID = NA_Slow_INACT_TAG + settingsNumber  //Increment for each new record type
+
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure NaInactVoltagePreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+uchar  comment[MAX_STRING]
+double firstStepDur //in ms
+double firstStepAmpInit //in mV
+double firstStepAmpLimit //in mV
+double firstStepAmpInterval//in mV
+double secondStepDur //in ms
+double secondStepAmp //in mV
+double holdPotential //in mV
+double interTrialInterval //in s  No longer used.
+uint16 reserved[100] 
+EndStructure
+
+Function LoadNaInactVoltagePreferences(prefs, settingsNumber)
+	STRUCT NaInactVoltagePreferences &prefs
+	Variable settingsNumber
+	Variable kPreferencesRecordID = NA_INACT_VOLTAGE_TAG+settingsNumber  //Increment for each new record type
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+		
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.firstStepDur = 10
+		prefs.firstStepAmpInit  = -60
+		prefs.firstStepAmpLimit = 30
+		prefs.firstStepAmpInterval = 5
+		prefs.secondStepDur = 5
+		prefs.secondStepAmp = 15
+
+		prefs.holdPotential = -50
+		prefs.interTrialInterval = 2 //No longer used
+		
+				
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetNaInactVoltagePreferences(prefs, settingsNumber)
+	STRUCT NaInactVoltagePreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	Variable kPreferencesRecordID = NA_INACT_VOLTAGE_TAG + settingsNumber //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure RampVCPreferences
+
+uchar  comment[MAX_STRING]
+double holding  //mV
+double baseline //mV
+
+double  startAmp //mV
+double finalAmp//mV
+double rampDuration //ms
+
+EndStructure
+
+Function LoadRampVCPreferences(prefs)
+	STRUCT RampVCPreferences &prefs
+
+	Variable kPreferencesRecordID = RAMPVC_TAG//Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+				
+		prefs.holding = -50
+		prefs.baseline = -50
+		prefs.startAmp = -50
+		prefs.finalAmp = 20
+		prefs.rampDuration = 100
+
+	endif
+End
+
+Function SetRampVCPreferences(prefs)
+	STRUCT RampVCPreferences &prefs
+
+	Variable kPreferencesRecordID = RAMPVC_TAG  //Increment for each new record type
+
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure RampCCPreferences
+
+uchar  comment[MAX_STRING]
+
+
+double  startAmp //pA
+double finalAmp//pA
+double rampSlope //pA/s
+
+EndStructure
+
+Function LoadRampCCPreferences(prefs)
+	STRUCT RampCCPreferences &prefs
+
+	Variable kPreferencesRecordID = RAMPCC_TAG//Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.startAmp = -50
+		prefs.finalAmp = 50
+		prefs.rampSlope = 100
+
+	endif
+End
+
+Function SetRampCCPreferences(prefs)
+	STRUCT RampCCPreferences &prefs
+
+	Variable kPreferencesRecordID = RAMPCC_TAG  //Increment for each new record type
+
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure NaSpikeInactPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+
+uchar  precom[MAX_STRING]
+double stepVoltage //mV
+uchar  stimName[MAX_STRING]
+uchar deltaTs[MAX_STRING] //ms list
+double holding  //mV
+
+uint16 reserved[100] 
+EndStructure
+
+Function LoadNaSpikeInactPreferences(prefs)
+	STRUCT NaSpikeInactPreferences &prefs
+
+	Variable kPreferencesRecordID = NA_SPIKE_INACT_TAG//Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.precom[i] = 0
+		endfor
+				
+		prefs.stepVoltage = 15
+		prefs.stimName = "stimName"
+		prefs.deltaTs = "1,2,3,4,5,7,10,50,100,500,1000"
+		prefs.holding = -50
+		
+	endif
+End
+
+Function SetNaSpikeInactPreferences(prefs)
+	STRUCT NaSpikeInactPreferences &prefs
+
+	Variable kPreferencesRecordID = NA_SPIKE_INACT_TAG  //Increment for each new record type
+
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+Structure PulseTrainPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+
+uchar  comment[MAX_STRING]
+uint32 nPulses
+double pulseAmp //pA
+double pulseWidth //ms
+uchar deltaTs[MAX_STRING] //ms
+uint16 reserved[100] 
+EndStructure
+
+Function LoadPulseTrainPreferences(prefs, settingsNumber)
+	STRUCT PulseTrainPreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	Variable kPreferencesRecordID = PULSE_TRAIN_TAG + settingsNumber//Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.nPulses = 10
+		prefs.pulseAmp = 20
+		prefs.pulseWidth = 5
+		prefs.deltaTs = "10, 20, 30, 40, 50"
+
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetPulseTrainPreferences(prefs, settingsNumber)
+	STRUCT PulseTrainPreferences &prefs
+	Variable settingsNumber
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	Variable kPreferencesRecordID = PULSE_TRAIN_TAG + settingsNumber  //Increment for each new record type
+
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure SettingsNumberPreferences
+int32 isolatorStim
+int32 stepRun
+int32 viewer
+EndStructure
+
+Function LoadSettingsNumberPreferences(prefs)
+	STRUCT SettingsNumberPreferences &prefs
+	Variable kPreferencesRecordID = SETTINGSNUMBER_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+
+		prefs.isolatorStim = 0
+		prefs.stepRun = 0
+		prefs.viewer = 0
+		
+
+	endif
+End
+
+Function SetSettingsNumberPreferences(prefs)
+	STRUCT SettingsNumberPreferences &prefs
+	Variable kPreferencesRecordID = SETTINGSNUMBER_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+Function GetSettingsNumber(TitleString, FieldString)
+	String TitleString, FieldString
+	
+	Struct SettingsNumberPreferences prefsA
+	LoadSettingsNumberPreferences(prefsA)
+	Variable settingsNumber = prefsA.stepRun
+	
+	prompt settingsNumber, FieldString
+	DoPrompt TitleString, settingsNumber
+	if(V_Flag)
+		abort
+	endif
+	prefsA.stepRun = settingsNumber
+	SetSettingsNumberPreferences(prefsA)
+	return settingsNumber
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure WhiteNoisePreferences
+
+uchar  comment[MAX_STRING]
+
+int32 seed
+double offset //pA
+double standardD //pA
+double interval //ms
+double duration
+uint16 durationUnits
+EndStructure
+
+Function LoadWhiteNoisePreferences(prefs)
+	STRUCT WhiteNoisePreferences &prefs
+	Variable kPreferencesRecordID = WHITENOISE_TAG  //Increment for each new record type
+
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+
+		Variable i
+		for(i=0; i<MAX_STRING; i+=1)
+			prefs.comment[i] = 0
+		endfor
+		
+		prefs.seed = 4357
+		prefs.offset = 0
+		prefs.standardD = 10
+		prefs.interval = 10
+		prefs.duration = 5
+		prefs.durationUnits = 2
+
+
+	endif
+End
+
+Function SetWhiteNoisePreferences(prefs)
+	STRUCT WhiteNoisePreferences &prefs
+	Variable kPreferencesRecordID = WHITENOISE_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure MultiChanPreferences
+
+
+//Global Characterstics
+uchar  comment[MAX_STRING]
+double duration //ms
+double interTrialInterval//s
+uint32 nTrials
+uint32 channel0
+uint32 channel1
+uint32 isolator
+
+
+EndStructure
+
+Function LoadMultiChanPreferences(prefs, settingsNumber)
+	STRUCT MultiChanPreferences &prefs
+	Variable settingsNumber
+	Variable channel //0 or 1
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+
+	
+	Variable kPreferencesRecordID = MULTICHAN_TAG +  settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)	
+	
+		prefs.comment = "comment"	
+		prefs.duration = 5000
+		prefs.interTrialInterval = 1
+		prefs.nTrials = 1
+		prefs.channel0 = 1
+		prefs.channel1 = 0
+		prefs.isolator = 1
+
+	endif
+End
+
+Function SetMultiChanPreferences(prefs, settingsNumber)
+	STRUCT MultiChanPreferences &prefs
+	Variable settingsNumber
+	Variable channel //0 or 1
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	
+	Variable kPreferencesRecordID =MULTICHAN_TAG +  settingsNumber//Increment for each new record type
+
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure MCLevelsPreferences
+
+
+//CC vs VC
+double ccDur //ms
+double vcDur//ms
+uint32 pulseMode  //CC=0 or VC=1
+
+double prePulse //ms
+double durPulseA //ms
+double ampPulseA //(pA for CC, mV for VC)
+double durPulseB //ms
+double ampPulseB //(pA for CC, mV for VC)
+
+
+EndStructure
+
+Function LoadMCLevelsPreferences(prefs, settingsNumber, channel)
+	STRUCT MCLevelsPreferences &prefs
+	Variable settingsNumber
+	Variable channel //0 or 1
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	if(channel ==1)
+		settingsNumber +=10
+	endif
+	
+	Variable kPreferencesRecordID = MCLEVELS_TAG +  settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		prefs.ccDur = 5000
+		prefs.vcDur = 0
+		prefs.pulseMode = 0
+		prefs.prePulse = 1000
+		prefs.durPulseA = 500
+		prefs.ampPulseA = -100
+		prefs.durPulseB = 500
+		prefs.ampPulseB = 100
+
+	endif
+End
+
+Function SetMCLevelsPreferences(prefs, settingsNumber, channel)
+	STRUCT MCLevelsPreferences &prefs
+	Variable settingsNumber
+	Variable channel //0 or 1
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	if(channel ==1)
+		settingsNumber +=10
+	endif
+	
+	Variable kPreferencesRecordID =MCLEVELS_TAG +  settingsNumber//Increment for each new record type
+
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure MCIsoStimPreferences
+
+
+//Output to Stimulus Isolator
+double stim1Delay //ms
+uchar pulseWidths[MAX_STRING]
+uchar interPulseIntervals[MAX_STRING]
+uchar nPulses[MAX_STRING]
+
+uint32 stim2Active
+double stim2Delay //ms
+uint32 fitFirstEpsc //0: No, 1: Yes
+double relativeRestingTime  //ms
+double relativeStartFitTime  //ms
+double relativeEndFitTime //ms
+
+
+EndStructure
+
+Function LoadMCIsoStimPreferences(prefs, settingsNumber)
+	STRUCT MCIsoStimPreferences &prefs
+	Variable settingsNumber
+
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+
+	
+	Variable kPreferencesRecordID = MCISOSTIM_TAG +  settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		prefs.stim1Delay = 1000
+		prefs.pulseWidths = "2"
+		prefs.interPulseIntervals = "6"
+		prefs.nPulses = "50"
+		prefs.stim2Active = 0
+		prefs.stim2delay = 1002
+		
+		prefs.fitFirstEpsc = 1
+		prefs.relativeRestingTime = -3
+		prefs.relativeStartFitTime = 1
+		prefs.relativeEndFitTime = 5
+
+	endif
+End
+
+Function SetMCIsoStimPreferences(prefs, settingsNumber)
+	STRUCT MCIsoStimPreferences &prefs
+	Variable settingsNumber
+
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	
+	Variable kPreferencesRecordID =MCISOSTIM_TAG +  settingsNumber//Increment for each new record type
+
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure MCIsoStimFilePreferences
+
+
+//Output to Stimulus Isolator
+double stim1Delay //ms
+double pulseWidth
+uchar pulseTimesFile[MAX_STRING]
+
+uint32 stim2Active
+double stim2Delay //ms
+uint32 fitFirstEpsc //0: No, 1: Yes
+double relativeRestingTime  //ms
+double relativeStartFitTime  //ms
+double relativeEndFitTime //ms
+
+
+EndStructure
+
+Function LoadMCIsoStimFilePreferences(prefs, settingsNumber)
+	STRUCT MCIsoStimFilePreferences &prefs
+	Variable settingsNumber
+
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+
+	
+	Variable kPreferencesRecordID = MCISOSTIM_FILE_TAG +  settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		prefs.stim1Delay = 1000
+		prefs.pulseWidth = 2
+		prefs.pulseTimesFile = ""
+		prefs.stim2Active = 0
+		prefs.stim2delay = 1002
+		
+		prefs.fitFirstEpsc = 1
+		prefs.relativeRestingTime = -3
+		prefs.relativeStartFitTime = 1
+		prefs.relativeEndFitTime = 5
+
+	endif
+End
+
+Function SetMCIsoStimFilePreferences(prefs, settingsNumber)
+	STRUCT MCIsoStimFilePreferences &prefs
+	Variable settingsNumber
+
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+
+	
+	Variable kPreferencesRecordID =MCISOSTIM_FILE_TAG +  settingsNumber//Increment for each new record type
+
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+Structure MCWaveformPreferences
+
+
+//CC vs VC
+double ccDur //ms
+double vcDur//ms
+//Add holding?
+
+uchar stimName[MAX_STRING]
+
+
+EndStructure
+
+Function LoadMCWaveformPreferences(prefs, settingsNumber, channel)
+	STRUCT MCWaveformPreferences &prefs
+	Variable settingsNumber
+	Variable channel //0 or 1
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	if(channel ==1)
+		settingsNumber +=10
+	endif
+	
+	Variable kPreferencesRecordID = MCWAVEFORM_TAG +  settingsNumber //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)
+		
+		prefs.ccDur = 0
+		prefs.vcDur = 5000
+		prefs.stimName = "WaveName"
+
+	endif
+End
+
+Function SetMCWaveformPreferences(prefs, settingsNumber, channel)
+	STRUCT MCWaveformPreferences &prefs
+	Variable settingsNumber
+	Variable channel //0 or 1
+	
+	if(settingsNumber > 9)
+		DoAlert 0, "Requested settingsNumber is too high."
+		abort
+	endif
+	
+	if(channel ==1)
+		settingsNumber +=10
+	endif
+	
+	Variable kPreferencesRecordID =MCWAVEFORM_TAG +  settingsNumber//Increment for each new record type
+
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Structure IFPlotPreferences
+uchar baseName[MAX_STRING]
+double relativeStart
+double analysisDuration
+double freqCutoff
+uint32 stepAdaptation
+uchar epochsToIgnore[MAX_STRING]
+EndStructure
+
+Function LoadIFPlotPreferences(prefs)
+	STRUCT IFPlotPreferences &prefs
+	Variable kPreferencesRecordID = IFPLOT_TAG  //Increment for each new record type
+	
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0)	
+		
+		Variable i
+		prefs.baseName = ""
+
+		prefs.relativeStart = 0
+		prefs.analysisDuration = 1000
+		prefs.freqCutoff = 80.0
+		prefs.stepAdaptation = 1
+		prefs.epochsToIgnore = ""
+
+	endif
+End
+
+Function SetIFPlotPreferences(prefs)
+	STRUCT IFPlotPreferences &prefs
+	Variable kPreferencesRecordID = IFPLOT_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+Structure RinPreferences
+uint32 version  //Currently 100, increment each time the structure is changed.
+uint32 peak
+uint32 mempotential
+
+uint16 reserved[100] 
+EndStructure
+
+Function LoadRinPreferences(prefs)
+	STRUCT RinPreferences &prefs
+	Variable kPreferencesRecordID = RIN_TAG  //Increment for each new record type
+	
+	Variable currentPrefsVersion = 100  
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 || prefs.version!=currentPrefsVersion)
+		prefs.version = currentPrefsVersion	
+		
+		Variable i
+			
+		prefs.peak = 1
+		prefs.mempotential = 0
+			
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetRinPreferences(prefs)
+	STRUCT RinPreferences &prefs
+	Variable kPreferencesRecordID = RIN_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+Structure RinFitPreferences
+uchar epochsToIgnore[100]
+
+uint16 reserved[100] 
+EndStructure
+
+Function LoadRinFitPreferences(prefs)
+	STRUCT RinFitPreferences &prefs
+	Variable kPreferencesRecordID = RIN_FIT_TAG  //Increment for each new record type
+	
+	
+	LoadPackagePreferences/MIS=1 kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+
+	//If unable to load prefences, load from defaults.
+	if(V_flag!=0 || V_bytesRead==0 )
+			
+		Variable i
+			
+		prefs.epochsToIgnore = ""
+			
+		for(i=0; i<100; i+=1)
+			prefs.reserved[i] = 0
+		endfor
+	endif
+End
+
+Function SetRinFitPreferences(prefs)
+	STRUCT RinFitPreferences &prefs
+	Variable kPreferencesRecordID = RIN_FIT_TAG //Increment for each new record type
+	
+	SavePackagePreferences kPackageName, kPreferencesfileName, kPreferencesRecordID, prefs
+End
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+Structure SpontParamsPreferences
+double startTime
+double endTime
+
+EndStructure