def populatemytables(paralel=True, cores=9): IDs = { k: v for k, v in zip(*lab.WaterRestriction().fetch( 'water_restriction_number', 'subject_id')) } if paralel: schema = dj.schema(pipeline_tools.get_schema_name('behavior_foraging'), locals()) schema.jobs.delete() ray.init(num_cpus=cores) for runround in [1]: arguments = { 'display_progress': False, 'reserve_jobs': True, 'order': 'random' } print('round ' + str(runround) + ' of populate') result_ids = [] for coreidx in range(cores): result_ids.append( populatemytables_core_paralel.remote(arguments, runround)) ray.get(result_ids) arguments = {'display_progress': True, 'reserve_jobs': False} populatemytables_core(arguments, runround) ray.shutdown() else: for runround in [1]: arguments = { 'display_progress': True, 'reserve_jobs': False, 'order': 'random' } populatemytables_core(arguments, runround)
import datajoint as dj import pipeline.lab as lab #, ccf from pipeline.pipeline_tools import get_schema_name import pipeline.experiment as experiment import numpy as np schema = dj.schema(get_schema_name('tracking')) #[experiment] # NOQA flake8 @schema class VideoTrialNum(dj.Manual): definition = """ ->experiment.Session video_trial_num: smallint # how many trials for recorded because usually the last couple trials are not recorded --- """ @schema class TrackingDevice(dj.Lookup): definition = """ tracking_device: varchar(20) # device type/function --- tracking_position: varchar(20) # device position sampling_rate: decimal(8, 4) # sampling rate (Hz) tracking_device_description: varchar(100) # device description """ contents = [('Camera 0', 'side_face', 1 / 0.0034, 'Chameleon3 CM3-U3-13Y3M-CS (FLIR)'), ('Camera 1', 'front_face', 1 / 0.0034,
import datajoint as dj from pipeline.pipeline_tools import get_schema_name schema = dj.schema(get_schema_name('lab'),locals()) #schema = dj.schema('rozmar_foraging_lab', locals()) @schema class Person(dj.Manual): definition = """ username : varchar(24) ---- fullname : varchar(255) """ @schema class Rig(dj.Manual): definition = """ rig : varchar(24) --- room : varchar(20) # example 2w.342 rig_description : varchar(1024) """ @schema class AnimalSource(dj.Lookup): definition = """ animal_source : varchar(30) """ contents = zip(['Jackson Labs', 'Allen Institute', 'Charles River', 'MMRRC', 'Taconic', 'Other'])
import datajoint as dj # ============================================================================= # import numpy as np # import pipeline.lab as lab #, ccf from pipeline.pipeline_tools import get_schema_name #from . import get_schema_name # schema = dj.schema(get_schema_name('experiment'), locals()) #schema = dj.schema('rozmar_foraging_experiment',locals()) # ============================================================================= #schema = dj.schema('rozmar_tutorial', locals()) @schema class BrainLocation(dj.Manual): definition = """ brain_location_name: varchar(32) # unique name of this brain location (could be hash of the non-primary attr) --- -> lab.BrainArea -> lab.Hemisphere -> lab.SkullReference """ @schema class Session(dj.Manual): definition = """ -> lab.Subject session : smallint # session number
import datajoint as dj # ============================================================================= # import numpy as np # import pipeline.lab as lab#, ccf import pipeline.experiment as experiment#, ccf from pipeline.pipeline_tools import get_schema_name #from . import get_schema_name # schema = dj.schema(get_schema_name('ephys_patch'),locals()) #schema = dj.schema('rozmar_foraging_experiment',locals()) # ============================================================================= #schema = dj.schema('rozmar_tutorial', locals()) @schema class CellType(dj.Lookup): definition = """ # cell_type : varchar(100) --- cell_type_description : varchar(4000) """ contents = [ ('pyr', 'putative pyramidal'), ('int', 'putative interneuron'), ('glia', 'astrocyte or oligodendrocyte precursor like cell'), ('unidentified', 'can''t tell based on electrophysiological recording') ]
dj.config["enable_python_native_blobs"] = True import pipeline.lab as lab #, ccf from pipeline.pipeline_tools import get_schema_name import pipeline.experiment as experiment import pipeline.tracking as tracking import numpy as np import math import scipy as sp import matplotlib import matplotlib.pyplot as plt import statistics as st import math import scipy.signal import pandas as pd schema = dj.schema(get_schema_name('bottom_tongue')) #[experiment] # NOQA flake8 def movmean( interval, window_size ): # calculate the moving average; the beginning and the end has some issues window = np.ones(int(window_size)) / float(window_size) return np.convolve(interval, window, 'same') def cart2pol(x, y): theta = np.nan rho = [] for i in enumerate(x):
import datajoint as dj import pipeline.lab as lab #, ccf import pipeline.experiment as experiment import pipeline.ephys_patch as ephys_patch import pipeline.ephysanal as ephysanal import pipeline.imaging as imaging from pipeline.pipeline_tools import get_schema_name schema = dj.schema(get_schema_name('imaging_gt'), locals()) # TODO ez el van baszva import numpy as np import scipy #%% @schema class CellMovieCorrespondance(dj.Computed): definition = """ -> ephys_patch.Cell -> imaging.Movie --- sweep_numbers = null : longblob # sweep numbers that """ def make(self, key): #% # key = { 'subject_id': 462149, 'session':1,'cell_number':1,'movie_number':11} session_time = (experiment.Session() & key).fetch('session_time')[0] cell_time = (ephys_patch.Cell() & key).fetch('cell_recording_start')[0] cell_sweep_start_times = (ephys_patch.Sweep() & key).fetch('sweep_start_time')
import numpy as np import matplotlib.pyplot as plt import datajoint as dj import pandas as pd import scipy.signal as signal import scipy.ndimage as ndimage from pipeline import pipeline_tools, lab, experiment, behavioranal, ephys_patch #dj.conn() #%% schema = dj.schema(pipeline_tools.get_schema_name('ephys-anal'),locals()) #%% @schema class ActionPotential(dj.Computed): definition = """ -> ephys_patch.Sweep ap_num : smallint unsigned # action potential number in sweep --- ap_max_index=null : int unsigned # index of AP max on sweep ap_max_time=null : decimal(8,4) # time of the AP max relative to recording start """ def make(self, key): #%% #key = {'subject_id': 454263, 'session': 1, 'cell_number': 1, 'sweep_number': 62} #print(key) keynow = key.copy() if len(ActionPotential()&keynow) == 0: pd_sweep = pd.DataFrame((ephys_patch.Sweep()&key)*(ephys_patch.SweepResponse()&key)*(ephys_patch.SweepStimulus()&key)*(ephys_patch.SweepMetadata()&key)) if len(pd_sweep)>0:
import datajoint as dj import pipeline.lab as lab #, ccf #import pipeline.experiment as experiment #import pipeline.ephys_patch as ephys_patch #import pipeline.ephysanal as ephysanal from pipeline.pipeline_tools import get_schema_name schema = dj.schema(get_schema_name('imaging'), locals()) from PIL import Image import numpy as np import os #%% @schema class Movie(dj.Imported): definition = """ -> experiment.Session movie_number : smallint --- movie_name : varchar(200) # movie name movie_x_size : double # (pixels) movie_y_size : double # (pixels) movie_frame_rate : double # (Hz) movie_frame_num : int # number of frames movie_start_time : decimal(12, 6) # (s) from session start # maybe end_time would also be useful movie_pixel_size : decimal(5,2) # in microns """ @schema class MovieFrameTimes(dj.Imported):