-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertNWB.py
126 lines (108 loc) · 8.07 KB
/
convertNWB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
######################################################################################################################
# Combine Behavioral Data from *.nev (markers) & *.YAML files into a NWB file
# file format follow YAULAB convention of the task : visual cues + 2 shakers + footbar + eye tracking + pupil diameter
# If Analog and Raw-Neural data is collected, it will be added to the NWBfile
######################################################################################################################
from constructorNWB import get_filePaths_to_extract, createNWBfile
######################################################################################################################
# PATH/FILE INFORMATION:
# If "fileName = None" it will search for all the YAML files within the "folderName"
######################################################################################################################
folderName = 'Y:\Data_Albus\Albus_NeuralData\Albus-S1'
fileName = None
##########################################################################################################
# EXPERIMENTAL INFORMATION NEEDED TO CREATE .nwb.
# This information is not found in .yaml not in .nev/.ns5 files
##########################################################################################################
# DEFAULT FOR ALBUS:
Experiment_Description = "Amplitude categorization of unimanual (cued) stimuli with or without bimanual (distractor) stimuli. Decisions are reported by eye responses. \
\nAmplitudes above than 28 microns are reported as high-category and matched to Red-visual cue locations.\
Amplitudes lower than 28 microns are reported as low and matched to Yellow-visual cue locations.\
Warm temperatures can be delivered through the mechanical probe\
Stimulation can also be delivered by Intracortical MicroStimulation"
Stimulus_Notes = "The animal has both hands restrined with the palms facing up. Two small probes (~3 mm diamater each) were placed\
on top of left & right finger tips, respectively. An accelerometer is attached to each probe. Command-voltage and accelerometer signals are recorded.\
Thermal stimulation can be delivered through the mechanical probe, the thermistor signal is recorded.\
The animal is looking at a monitor (viewing distance 49 cm) where visual cues are presented. The fixation cue\
and onset of visual events are recorded using one photodiode signal for each.\
Intracortical Microstimulation can be delivered by up to 4 electrode-contacts. Each microStimulation period (a.k.a. stim-epoch) consist of up to 3 consecutive trains of pulses"
Experimenters= [ "Chen, Jian", "Lin, Jing", "Rust, Dain", "Ung, Kevin", "Vergara de la Fuente, Jose", "Yau, Jeffrey M"]
KeywordExperiment = ['tactile', 'visual', 'rhesus monkey', 'vibration', 'amplitude categorization',
'primary somatosensory cortex', 'single neuron', 'bimanual touch', 'ICMS'
]
related_publications = None
##########################################################################################################
# PARAMETERS TO GET AND PREPROCESS ANALOG SIGNALS FROM RIPPLE (.ns5):
##########################################################################################################
analogEye = {
'exists_eyeHorizontal': True, # Whether or not Horizontal EyeData signal was recorded (set to False if you don't want to extract EyeData HorizontalPosition)
'exists_eyePupil': True, # Whether or not Pupilometry EyeData signal was recorded (set to False if you don't want to extract Pupil diamater EyeData)
'eyeTrackID': None, # extracted from YauLabInfo parameters, otherwise "Left" or "Right"
'eyeXYComments': None, # extracted from YauLabInfo parameters, otherwise add "Text" comments
'pupilDiameterComments': None # extracted from YauLabInfo parameters, otherwise add "Text" comments
}
analogAccl = {
'exists': True, # Whether or not Accelerometer signal was recorded (set to False if you don't want to extract ShakerTimeStamps)
'thresholdHigh_std': 15, # threshold in Standar Deviations (to process accelerometer the signal is Z-scored)
'thresholdLow_std': 5, # In case High threshold didn't get a signal, it will use this one (units = Standar Deviations, signal is z-scored)
'showPlot': False,
'showPlot_lowThreshold': True, # PLOT THOSE STIM WHERE SIGNAL WAS DETECTED USING LOW THRESHOLD PARAMETER
'showPlot_noDetected': True # PLOT THOSE STIM WHERE NO SIGNAL WAS DETECTED
}
analogFix = {
'exists': True, # Whether or not Photodiode-Fixation signal was recorded (set to False if it doesn't want to be analyzed)
'normThreshold': 0.2, # Threshold to detect Fixation ON, fixSignal is normalized between 0 - 1
'showPlot': False
}
analogVisualEvents = {
'exists': True, # Whether or not Photodiode-VisualEvents signal was recorded (set to False if it doesn't want to be analyzed)
'normThreshold': 0.2, # Threshold to detect Fixation ON, fixSignal is normalized between 0 - 1
'showPlot': False,
'showWarningPlot': False # PLOT THOSE TRIALS WHERE IT WAS DETECTED MORE EVENTS THAN EXPECTED (possible artifacts in photodiode signal due to screen flash?)
}
analogFeet = {
'exists': True, # Whether or not FootBar signal was recorded (set to False if you don't want to extract FootBar TimeStamps)
'chunkSizeSecs': 60, # Seconds to chunk Feet signal to detect events.
'showPlot': False
}
analogReward = {
'exists': True, # Whether or not Reward signal was recorded (set to False if it doesn't want to be analyzed)
'chunkSizeSecs': 60, # Seconds to chunk Reward signal to detect events.
'showPlot': False
}
analogTemp = {
'exists': True, # Whether or not Reward signal was recorded (set to False if it doesn't want to be analyzed)
'thermistorIDs': ['leftProbeTEMP'], # List of labels from thermistors. Making a list will help for future temperatures? e.g.: ['leftProbeTEMP', rightProbeTEMP]
}
##########################################################################################################
##########################################################################################################
if __name__ == '__main__':
##########################################################################################################
# GET THE YAML(s)-Path(s)
##########################################################################################################
# if "updateFiles = True", it will overwrite the ones already created
# Otherwise it will compile only the YAML files without an NWB-file
yamlFiles2convert = get_filePaths_to_extract(folderName=folderName, fileName=fileName, updateFiles = True)
##########################################################################################################
# CREATE NWB
##########################################################################################################
for filePathYAML_in in yamlFiles2convert:
createNWBfile(
filePathYAML=filePathYAML_in,
Stimulus_Notes=Stimulus_Notes,
KeywordExperiment=KeywordExperiment,
Experimenters=Experimenters,
Experiment_Description=Experiment_Description,
related_publications=related_publications,
analogEye = analogEye,
analogAccl=analogAccl,
analogFix=analogFix,
analogVisualEvents=analogVisualEvents,
analogFeet=analogFeet,
analogReward=analogReward,
analogTemp=analogTemp,
TimeZone=None, # extracted from YauLabInfo parameters
process_INdisk = True, # it will copy the files into the same disk/partition as the NWBenv, It will help with I/O speed vs doing everything from the server
raw_by_ElectrodeGroup = True, # It will concatenate channels from the same ElectrodeGroup/probe. If False, it will create an "Acquisition" container per channel
verbose=True
)