Пример #1
0
import os
import retinotopic_mapping.DisplayLogAnalysis as dla
import NeuroAnalysisTools.NwbTools as nt

curr_folder = os.path.dirname(os.path.realpath(__file__))
os.chdir(curr_folder)

nwb_fn = [f for f in os.listdir(curr_folder) if f[-4:] == '.nwb'][0]
nwb_f = nt.RecordedFile(nwb_fn)

stim_pkl_fn = [f for f in os.listdir(curr_folder) if f[-4:] == '.pkl'][0]
stim_log = dla.DisplayLogAnalyzer(stim_pkl_fn)

nwb_f.add_visual_display_log_retinotopic_mapping(stim_log=stim_log)
nwb_f.close()
notebook_path = os.path.join(curr_folder, 'notebook.txt')
with open(notebook_path, 'r') as ff:
    notes = ff.read()

general = nt.DEFAULT_GENERAL
general['experimenter'] = experimenter
general['subject']['subject_id'] = mouse_id
general['subject']['genotype'] = genotype
general['subject']['sex'] = sex
general['subject']['age'] = age
general['optophysiology'].update({'imaging_plane_0': {}})
general['optophysiology']['imaging_plane_0'].update({'indicator': indicator})
general['optophysiology']['imaging_plane_0'].update(
    {'imaging_rate': imaging_rate})
general['optophysiology']['imaging_plane_0'].update(
    {'imaging_depth': imaging_depth})
general['optophysiology']['imaging_plane_0'].update(
    {'location': imaging_location})
general['optophysiology']['imaging_plane_0'].update({'device': imaging_device})
general['optophysiology']['imaging_plane_0'].update(
    {'excitation_lambda': imaging_excitation_lambda})
general['notes'] = notes

file_name = date_recorded + '_M' + mouse_id + '_' + sess_num + '.nwb'

rf = nt.RecordedFile(os.path.join(curr_folder, file_name),
                     identifier=file_name[:-4],
                     description='')
rf.add_general(general=general)
rf.close()
Пример #3
0
                          background=background)
# =================================================================================

# ======================= Set Stimuli Sequence ====================================
all_stim = [uc, fc, sl, sn, lsn, dgc, sgc, si, ss]
stim_seq = [all_stim[stim_ind] for stim_ind in cs_stim_ind_sequence]
cs.set_stimuli(stimuli=stim_seq, static_images_path=static_images_path)
# =================================================================================

# =============================== display =========================================
ds.set_stim(cs)
log_path, log_dict = ds.trigger_display()
# =============================== display =========================================


# =============================== convert log to .nwb =============================
import os
import WarpedVisualStim.DisplayLogAnalysis as dla
import NeuroAnalysisTools.NwbTools as nt
log_folder, log_fn = os.path.split(log_path)
log_nwb_path = os.path.splitext(log_path)[0] + '.nwb'
save_f = nt.RecordedFile(filename=log_nwb_path, identifier=os.path.splitext(log_fn)[0], description='')
stim_log = dla.DisplayLogAnalyzer(log_path)
save_f.add_visual_display_log_retinotopic_mapping(stim_log=stim_log)
save_f.close()
# =============================== convert log to .nwb =============================

# =============================== show plot========================================
plt.show()
# =================================================================================