from nbdev.showdoc import *
%load_ext autoreload
%autoreload 2

synchro.nested_stims

Functions to synchronize data from QDSpy stimuli that consist of presenting a sequence of shorter stimuli. Often those are compiled shortly before their presentation so they need different handling

get_stim_ids[source]

get_stim_ids(log, record_time, lastmodif_time)

Obtain the correct name of the stimulus, based on the name that appears in the QDSpy log

This is needed if no central database of compiled stimuli is used, but instead stimuli are compiled in QDSpy every time before they are presented.

params:

- log: log object generated by get_QDSpy_logs
- record_time: the stimulus presentation time, as calculated by subtracting stimulus duration from lastmodif_time
- lastmodif_time: the timestamp of the .npy file (time of compilation, assumed to be only seconds before record_time)

returns:

- stim_ids: Correct stim_id for the stimulus presented after the current log stimulus start

get_synced_file[source]

get_synced_file(stim_list_dir, stim_id)

Find the stimulus in the stimulus list directory that is temporally closest to the stimulus in the log. Works based on the modification time of the stimulus (i.e. expects stimulus to be compiled shortly before display). Input:

- stim_list_dir: fullpath to stimuli, string
- stim_id: stimulus read from QDSpy log, theonerig.synchro.extracting.Stimulus object

Output:

- stim: filename of the stimulus that needs loading, str

get_synced_file_precompile[source]

get_synced_file_precompile(stim_list_dir, stim_id)

get_stim_dict[source]

get_stim_dict(stim_dict_path, stim_filename)

Get the correct dictionary file that decodes the ints that encode the stimulus sequence. Applicable to nested stimuli, whose intensity.npy file contains only a list of integers.

params:

- stim_dict_path: [string], the path to the directory where all dicts are stored
- stim_filename: [string], the name of the stimulus, make sure that stim_id from the QDSpy log and the name of the dictionary match

cluster_by_list[source]

cluster_by_list(data, frame_timepoints, frame_signals, stim_list)

Assign the stimulus identity values from stim_list to the frames in data. stim_list contains only the sequence of stimuli. Those need to be expanded. Opposed to cluster_frame_signals and cluster_by_epochs no AUC operation is performed. Input:

- data: raw data used to compute the stimulus times
- frame_timepoints: timepoints delimiting each frame
- frame_signals: binary 1-D numpy array indicating if high_threshold was passed in 'detect_frames'
- stim_list: 1-D numpy array containing the sequence of the stimuli presented

Output:

- frame_signals: [same size as frame_timepoints] stim_signals list containing the correct value from
    stim_list at every entry

find_stim_onsets[source]

find_stim_onsets(frame_signals)

Get the frame timepoints during which the stimuli started and ended. Crop out the last two ones that are currently just an offset marker.

params:

- frame_signals: processed signal from the Photodiode files, containing the marker information

returns:

- epoch_end: the frame timepoints of the offset signal
- stim_change: the frame timepoints of every stimulus on and offset

append_tread_movement[source]

append_tread_movement(reM, epoch_counter, treadmill_data, ref_timepoints)

Append treadmill data to the record Master

Always make sure that the alignment is correct using ```find_starting_position.ipynb```
  File "<ipython-input-5-e7cbb7229119>", line 2
    Always make sure that the alignment is correct using ```find_starting_position.ipynb```
           ^
SyntaxError: invalid syntax

append_to_reM[source]

append_to_reM(epoch_counter, reM, retain_template, stim_list_dir, stim_ids, record_time, photo_data, stim_code_dict, frame_tp, ref_timepoints, ref_signals, tom_stim_dir)

master_loop[source]

master_loop(log, retain_template, tom_stim_dir, sync_dir, calcium_dir, stim_list_dir, stim_dict_dir)