Manual Processing tools
reformat_event_labels(subject, session, task, data_directory, annotations_directory, extension=None)
This script takes the events files, reads the timestamps in, and organizes them suitably for the data_viewer. Outputs the events as a csv file :param subject: (str). Subject :param session: (str). Session :param task: (srt). Task the subject completed in this session :param data_directory: (Path). The Path object that points to the neuralynx data directory :param annotations_directory: (Path). The Path object that points to where the annotations file will go. :param extension: str optional. :return:
Source code in intracranial_ephys_utils/manual_process.py
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 | |
photodiode_check_viewer(subject, session, task, data_directory, annotations_directory, diagnostic=False, task_start=0.0, events_filename=None)
This script is a generalized dataviewer to look at a photodiode signal, and bring up the events. With the viewer, we can make annotations and save them to a csv file. Additionally, if the diagnostic optional parameter is set to True, this function will also preprocess the photodiode to check that the signal on TTL is good. :param subject: (string) The patient ID :param session: (string) Session of the experiment. Useful if patient completed more than one session of a task. :param task: (string) Which task :param data_directory: (Path object) Where the data lives :param annotations_directory: (Path object) Where we want to put the annotations of the data :param diagnostic: (bool) (optional) If True we will also plot diagnostics, and preprocess photodiode and overlay it. :param task_start: (float) (optional) The start time of the task :param events_filename: (str) (optional) The extension of the file (in case multiple datasets in the same folder) :return:
Source code in intracranial_ephys_utils/manual_process.py
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
photodiode_event_check_viewer(subject, session, task, dataset, labels, sampling_rate, annotations_directory)
This code will plot the ph_signal, the binarized signal and the computed event onsets and offsets with the goal of getting the types of events properly annotated. :param dataset: (np.array) :parma labels: (np.array) - label associated with dataset :param sampling_rate: (float) :param event_onsets: (np.array) :param event_offsets: (np.array) :param annotations_directory: (Path object) :return: .csv file
Source code in intracranial_ephys_utils/manual_process.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
data_clean_viewer(subject, session, task, annotations_directory, electrode_names, dataset, fs)
This function serves to look at lfp signals and look at which is the reference or to look at the macrowires and clean the data for epileptic activity Current: Only array functionality, so data should be hard loaded as an array for this function to work :param subject: (string) subject id :param session: (string) session id :param task: (string) task id :param annotations_directory: (Path) path object :param electrode_names: (1d array) :param dataset: (n_electrodes, n_timepoints) :param fs: (int) :return:
Source code in intracranial_ephys_utils/manual_process.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
write_timestamps(subject, session, task, event_folder, annotations_directory, local_data_directory, events_filename)
Looks in event folders for labels. Takse labels and converts them to machine time and places into a .txt file useful for spike sorting. :param subject: (string) Subject identifier :param session: (string) Session identifier (1 if subject only completed one run of the experiment. :param task: (string) Task identifier. The task or experiment subject completed. :param annotations_directory: This is the folder where manual annotations are found :param event_folder: This is the folder where events live (helpful to get global machine time) :param local_data_directory: This is where the microwire data to be sorted is :param events_filename: If multiple events exist :return: None. A txt file is generated with relative timestamps if needed, or not if not needed.
Source code in intracranial_ephys_utils/manual_process.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
su_timestamp_process(subject, session, task, data_directory, annotations_directory, results_directory)
Master script that runs basic pipeline to get timestamps file for sorting minimally using OSort Matlab scripts. :param subject: (str). Subject identifier :param session: (str). Session identifier, useful if subject ran more than one session. :param task: (str). Task identifier. The task the subject ran. :param data_directory: (Path). Path object to data where events file and photodiode file lives :param annotations_directory: (Path). Path object that points to where we'd like to store annotations and metadata. :param results_directory: (Path). Path object that points to where the timestampInclude.txt file will end up. Ideally ends up in spike_sorting folder alongside 'raw' folder that contains microwire .ncs files
Source code in intracranial_ephys_utils/manual_process.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
get_annotated_task_start_time(subject, session, task, annotations_directory)
This function serves as a helper function to grab the start and end times of the task, after annotating the photodiode script. Will only work if annotations file exists, and duration event has been made. Recall that loading in .ncs files relies on loading in many segments of variable length, so we typically load in more data than what start and end time would have you believe :param subject: :param session: :param task: :param annotations_directory: :return: start_time_sec (float) Start time in seconds for the task. Reference is the start of the file recording. :return: end_time_sec (float) End time in seconds for the task. Reference is the start of the file recording. :return: duration (float) Duration in seconds for the task.
Source code in intracranial_ephys_utils/manual_process.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |