from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events from pixtools import spike_rate, spike_times, utils # This plots the behavioural channels for a given trial for each session # Settings duration = 4 trial = 3 mice = [ #'C57_1343253', # has no behaviour 'C57_1343255', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) exp.set_cache(False) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') exp.process_behaviour() hits = exp.align_trials( ActionLabels.rewarded_push, Events.back_sensor_open, 'behavioural', duration=duration, )
import pandas as pd import seaborn as sns from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events from pixtools import spike_rate, responsiveness, utils mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) fig_dir = Path('~/duguidlab/visuomotor_control/figures') sns.set(font_scale=0.4) align_args = { "duration": 1, "min_depth": 500, "max_depth": 1200, } hits = exp.align_trials( ActionLabels.cued_shutter_push_full, Events.back_sensor_open,
from matplotlib_venn import venn2 from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events from pixtools import spike_rate mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') duration = 4 rec_num = 0 ## Spike rate plots hits = exp.align_trials( ActionLabels.cued_shutter_push_full, Events.back_sensor_open, 'spike_rate', duration=duration,
from pixels import Experiment from pixels.behaviours.pushpull import PushPull from pixtools import clusters, utils mice = [ "C57_1319786", "C57_1319781", "C57_1319784", "C57_1319783", "C57_1319782", "C57_1319785", ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', #'~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures/DS') # all clusters fig = clusters.depth_profile(exp, curated=False) plt.ylim([2000, -250]) plt.suptitle('Cluster depth profile uncurated') utils.save(fig_dir / f'cluster_depth_profile_uncurated') #fig = clusters.depth_profile(exp, curated=True) #plt.ylim([-250, 2000]) #plt.suptitle('Cluster depth profile curated')
import numpy as np import pandas as pd from pixels import Experiment from pixels.behaviours.reach import ActionLabels, Events, Reach from pixtools import spike_rate, utils mice = [ "HFR25", #"HFR29", ] exp = Experiment( mice, Reach, '~/duguidlab/visuomotor_control/neuropixels', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) fig_dir = Path('~/duguidlab/visuomotor_control/AZ_notes/npx-plots/expert') duration = 2 # select units units = exp.select_units( min_depth=0, max_depth=1200, #min_spike_width=0.4, name="cortex0-1200", )
import seaborn as sns from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events from pixtools import spike_times, utils mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') duration = 4 bin_ms = 100 #hits = exp.align_trials( # ActionLabels.cued_shutter_push_full, # Events.back_sensor_open, # 'spike_times', # duration=duration, #) #
from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events # Step 1: Load an experiment # # An experiment handles a group of mice that were trained in the same behaviour. It # stores data and metadata for all included sessions belonging to the list of mice # provided. The Experiment class is passed the mouse or list of mice, the class # definition for the behaviour they were trained in (imported from pixels.behaviours), # and the paths where it can find recording data (the folder containing 'raw', 'interim' # and 'processed' folders) and training metadata. # myexp = Experiment( 'MCos1497', # This can be a list LeverPush, '~/path/to/data', '~/path/to/metadata', ) # Step 2: Process raw data # # These methods each process a different type of raw data and save the output into the # 'processed' folder. The outputs are all resampled to 1kHz, and are saved as: # # - action labels (.npy) # - behavioural data (.h5) # - LFP data (.h5) # - spike data (.h5) # - sorted spikes (TODO) #
import seaborn as sns from pixels import Experiment from pixels.behaviours.leverpush import LeverPush from pixels.behaviours.pushpull import PushPull from pixels.behaviours.reach import Reach mthal = Experiment( [ # paper behaviour + opto 'C57_724', 'C57_1288723', 'C57_1288727', 'C57_1313404', # muscimol spread test 'C57_1318495', 'C57_1318496', 'C57_1318497', 'C57_1318498', ], LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) dirsens = Experiment( [ "C57_1319786", "C57_1319781", "C57_1319784", "C57_1319783",
import seaborn as sns from pixels import Experiment from pixels.behaviours.pushpull import PushPull, ActionLabels, Events from pixtools import spike_rate, utils mice = [ #"C57_1319786", "C57_1319781", #"C57_1319784", #"C57_1319783", ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', #'~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures/DS') duration = 4 rec_num = 0 hits = exp.align_trials(ActionLabels.rewarded_push, Events.back_sensor_open, 'behavioural') _, axes = plt.subplots(6, 1, sharex=True) channels = hits.columns.get_level_values('unit').unique() trial = 8 session = 0
import seaborn as sns from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events from pixtools import spike_times, utils mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', 'C57_1313404', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') duration = 4 rec_num = 0 select = { "min_depth": 500, "max_depth": 1200, "min_spike_width": 0.4, } hits = exp.align_trials(
import seaborn as sns from pixels import Experiment from pixels.behaviours.leverpush import LeverPush from pixtools import utils mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', 'C57_1313404', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) widths = exp.get_spike_widths( min_depth=500, max_depth=1200, ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') fig, axes = plt.subplots(len(exp) + 1, 1, sharex=True) plt.tight_layout() counts = [] pool = True
from pathlib import Path import matplotlib.pyplot as plt import seaborn as sns from pixels import Experiment from pixels.behaviours.reach import Reach, ActionLabels, Events from pixtools import spike_rate, utils mice = [ 'HFR29', #first session only on right PPC ] exp = Experiment( mice, Reach, '~/duguidlab/visuomotor_control/neuropixels', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/AZ_notes') # Envelope for plots ci = "sd" ## Select units rec_num = 0 duration = 2 units = exp.select_units( min_depth=200, max_depth=1400,
from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events from pixtools import utils mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') duration = 2 _, axes = plt.subplots(len(exp), 1) hits = exp.align_trials( ActionLabels.cued_shutter_push_full, Events.back_sensor_open, 'spike_rate', duration=duration, min_depth=500,
from pixels import Experiment from pixels.behaviours.reach import VisualOnly, ActionLabels, Events from pixtools import spike_rate, utils mice = [ 'HFR19', 'HFR20', #'HFR21', # poor quality session 'HFR22', 'HFR23', ] exp = Experiment( mice, VisualOnly, '~/duguidlab/visuomotor_control/neuropixels', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/AZ_notes') # Envelope for plots ci = "sd" ## Select units rec_num = 0 duration = 2 select = {
from pixels import Experiment from pixels.behaviours.reach import VisualOnly, ActionLabels, Events from pixtools import spike_rate, utils mice = [ #'HFR19', 'HFR20', #'HFR21', # poor quality session 'HFR22', 'HFR23', ] exp = Experiment( mice, VisualOnly, '~/duguidlab/visuomotor_control/neuropixels', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=1) fig_dir = Path('~/duguidlab/visuomotor_control/AZ_notes') # Envelope for plots ci = "sd" ## Select units rec_num = 0 duration = 2 units = exp.select_units(
import tensorflow as tf from pathlib import Path from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') def save(name): plt.gcf().savefig(fig_dir / name, bbox_inches='tight', dpi=300) ## run settings ses = exp[0] rec_num = 0
from pixels.behaviours.pushpull import ActionLabels, Events, PushPull from pixtools import utils fig_dir = Path('~/duguidlab/Direction_Sensitivity/neuropixels_figures') mice = [ "C57_1350950", "C57_1350951", "C57_1350952", #"C57_1350953", "C57_1350954", ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', ) rec_num = 0 duration = 4 sns.set_context("paper") units = exp.select_units( min_depth=550, max_depth=900, name="550-900", ) pushes = exp.get_aligned_spike_rate_CI( ActionLabels.rewarded_push_good_mi,
import pandas as pd import numpy as np from pixels import Experiment from pixels.behaviours.reach import VisualOnly, ActionLabels, Events from pixtools import spike_rate, utils mice = [ 'HFR20', 'HFR22', 'HFR23', ] exp = Experiment( mice, VisualOnly, '~/duguidlab/visuomotor_control/neuropixels', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) fig_dir = Path('~/duguidlab/visuomotor_control/AZ_notes/npx-plots/naive') # Envelope for plots, 95% confidence interval ci = 95 ## Select units duration = 2 units = exp.select_units( min_depth=0, max_depth=1200, #min_spike_width=0.4, name="cortex0-1200")
from pixtools import spike_rate, utils mice = [ "C57_1319786", "C57_1319781", "C57_1319784", "C57_1319783", "C57_1319782", "C57_1319785", ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', #'~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures/DS') duration = 4 rec_num = 0 ## Spike rate plots pushes = exp.align_trials( ActionLabels.rewarded_push, Events.back_sensor_open, 'spike_rate',
from pixels import Experiment from pixels.behaviours.pushpull import PushPull from pixtools import clusters, utils mice = [ "C57_1350950", "C57_1350951", "C57_1350952", #"C57_1350953", "C57_1350954", ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', ) fig_dir = Path('~/duguidlab/Direction_Sensitivity/neuropixels_figures') sns.set(font_scale=0.4) rec_num = 0 pyramidals_units = exp.select_units( min_depth=550, max_depth=900, min_spike_width=0.4, name="550-900-pyramidals", ) pyramidals = exp.get_spike_waveforms(units=pyramidals_units)
duration = 8 rec_num = 0 fig_dir = Path('~/duguidlab/visuomotor_control/figures') mice = [ #"C57_1350950", # no ROIs drawn "C57_1350951", # MI done #"C57_1350952", # MI done #"C57_1350953", # MI done #"C57_1350954", # MI done #"C57_1350955", # no ROIs drawn ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', ) hits = exp.align_trials( ActionLabels.rewarded_push, Events.back_sensor_open, 'motion_index', duration=duration, ) for i, session in enumerate(exp): fig, axes = plt.subplots(10, 1, sharex=True) for t in range(10):
duration = 4 rec_num = 0 fig_dir = Path('~/duguidlab/Direction_Sensitivity/neuropixels_figures') mice = [ #"C57_1350950", # no ROIs drawn "C57_1350951", # MI done "C57_1350952", # MI done #"C57_1350953", # MI done "C57_1350954", # MI done #"C57_1350955", # no ROIs drawn ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', ) units = exp.select_units( min_depth=550, max_depth=1200, name="550-1200", ) pushes = exp.align_trials( ActionLabels.rewarded_push_good_mi, Events.motion_index_onset, 'spike_rate', duration=duration, units=units,
from pixels.behaviours.pushpull import ActionLabels, Events, PushPull from pixtools import utils fig_dir = Path('~/duguidlab/Direction_Sensitivity/neuropixels_figures') mice = [ "C57_1350950", "C57_1350951", "C57_1350952", #"C57_1350953", # MI done, needs curation "C57_1350954", ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', ) rec_num = 0 duration = 4 pyramidals = exp.select_units( min_depth=550, max_depth=900, min_spike_width=0.4, name="550-900-pyramidals", ) interneurons = exp.select_units( min_depth=550,
import pandas as pd from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events from pixtools import utils mice = [ 'C57_724', 'C57_1288723', 'C57_1288727', 'C57_1313404', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures') rec_num = 0 select = { "min_depth": 500, "max_depth": 1200, "min_spike_width": 0.4, "sigma": 200, } hits = exp.get_aligned_spike_rate_CI(
from pixels import Experiment from pixels.behaviours.pushpull import ActionLabels, Events, PushPull from pixtools import spike_rate, utils fig_dir = Path('~/duguidlab/Direction_Sensitivity/neuropixels_figures') mice = [ "HFR20", "HFR22", "HFR23", ] exp = Experiment( mice, VisualOnly, '~/duguidlab/visuomotor_control/neuropixles', ) rec_num = 0 duration = 2 # select units units = exp.select_units( min_depth=0, max_depth=1200, #min_spike_width=0.4, name="cortex0-1200", ) start = 0.000
ses_m1_mth = 0 m1 = 0 # session 0 mth = 1 # session 0 ses_ipn_gpi = 1 ipn = 0 # session 1 gpi = 1 # session 1 mice = [ #'C57_1343253', # has no behaviour 'C57_1343255', ] exp = Experiment( mice, LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/figures/srf_grant') if rates_not_rasters: firing_rates = exp.align_trials( ActionLabels.rewarded_push, Events.back_sensor_open, 'spike_rate', duration=duration, ) # IPN
from pixels import Experiment from pixels.behaviours.leverpush import LeverPush, ActionLabels, Events # Step 1: Load an experiment # # An experiment handles a group of mice that were trained in the same behaviour. It # stores data and metadata for all included sessions belonging to the list of mice # provided. The Experiment class is passed the mouse or list of mice, the class # definition for the behaviour they were trained in (imported from pixels.behaviours), # and the paths where it can find recording data (the folder containing 'raw', 'interim' # and 'processed' folders) and training metadata. # myexp = Experiment( 'MCos1371', LeverPush, '~/duguidlab/thalamus_paper/Npx_data', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) # Step 2: Process raw data # # These methods each process a different type of raw data and save the output into the # 'processed' folder. The outputs are all resampled to 1kHz, and are saved as: # # - action labels (.npy) # - behavioural data (.h5) # - spike data (.h5) # - lfp data (.h5) # # This aligns, crops and downsamples behavioural data.
import matplotlib.pyplot as plt import seaborn as sns from pixels import Experiment from pixels.behaviours.reach import VisualOnly from pixtools import clusters, utils mice = [ ## 'HFR19', 'HFR20', ## 'HFR21', ## 'HFR22', ## 'HFR23', ] exp = Experiment( mice, VisualOnly, '~/duguidlab/visuomotor_control/neuropixels', '~/duguidlab/CuedBehaviourAnalysis/Data/TrainingJSON', ) sns.set(font_scale=0.4) fig_dir = Path('~/duguidlab/visuomotor_control/AZ_notes') fig = clusters.depth_profile(exp, curated=True, in_brain=True) plt.ylim([1750, -250]) plt.suptitle('Cluster depth profile') utils.save(fig_dir / f'cluster_depth_profile')
import seaborn as sns from pixels import Experiment from pixels.behaviours.pushpull import PushPull, ActionLabels, Events mice = [ "C57_1350950", "C57_1350951", "C57_1350952", #"C57_1350953", "C57_1350954", ] exp = Experiment( mice, PushPull, '~/duguidlab/Direction_Sensitivity/Data/Neuropixel', ) rec_num = 0 all_push_rts = [] med_push_rts = [] all_pull_rts = [] med_pull_rts = [] for i, ses in enumerate(exp): action_labels = ses.get_action_labels() # Just confirm each session has only one recording assert len(action_labels) == 1 actions = action_labels[rec_num][:, 0]