DjTools#

djtools.Analyze_AD_behavior()#

new version 10.31.2018 only difference is I throw out early datafiles with partial gapdur arrays (I switched to full gapdur arrays early on as soon as I found the “save time” bug)

Args:

arg1 (int): an argument arg2 (int): BatchPrep()

djtools.Analyze_AD_behavior_TEST()#

new version 10.31.2018 only difference is I throw out early datafiles with partial gapdur arrays (I switched to full gapdur arrays early on as soon as I found the “save time” bug)

djtools.Analyze_AD_behavior_sansanal()#

new version 10.31.2018 only difference is I throw out early datafiles with partial gapdur arrays (I switched to full gapdur arrays early on as soon as I found the “save time” bug)

djtools.BatchPrep#

function BatchPrep user options

djtools.CellListBuilder(varargin)#
button to add current directory to cell list

will automatically scan for clustered tetrode data % gives you a checklist of cells in that directory so you can keep or discard another button that opens a dialog box so you can browse to the desired directory add a checkbox for recursive scan

what does it do? It creates/appends a machine readable cell list this will be a text file with each cell, stimuli presented, other stuff. It would be nice to have it formatted in such a way that it can be used to analyze data.

to append to an existing cell list, we could have a dropdown menu of existing cell lists. Not sure where this would live.

djtools.CellListBuilderDir(varargin)#

modified from CellListBuilder to skip the step of automatically scanning for clustered tetrode data instead this just builds a list of directories

what does it do? It creates/appends a machine readable datadir list this will be a text file with each dir you select uses a button to add current directory to a cell list file

djtools.CellListBuilderKip1(varargin)#
button to add current directory to cell list

will automatically scan for clustered tetrode data % gives you a checklist of cells in that directory so you can keep or discard another button that opens a dialog box so you can browse to the desired directory add a checkbox for recursive scan

what does it do? It creates/appends a machine readable cell list this will be a text file with each cell, stimuli presented, other stuff. It would be nice to have it formatted in such a way that it can be used to analyze data.

to append to an existing cell list, we could have a dropdown menu of existing cell lists. Not sure where this would live.

djtools.CellListBuilderKip2(varargin)#
button to add current directory to cell list

will automatically scan for clustered tetrode data % gives you a checklist of cells in that directory so you can keep or discard another button that opens a dialog box so you can browse to the desired directory add a checkbox for recursive scan

what does it do? It creates/appends a machine readable cell list this will be a text file with each cell, stimuli presented, other stuff. It would be nice to have it formatted in such a way that it can be used to analyze data.

to append to an existing cell list, we could have a dropdown menu of existing cell lists. Not sure where this would live.

djtools.CellListBuilder_noslider(varargin)#
button to add current directory to cell list

will automatically scan for clustered tetrode data % gives you a checklist of cells in that directory so you can keep or discard another button that opens a dialog box so you can browse to the desired directory add a checkbox for recursive scan

what does it do? It creates/appends a machine readable cell list this will be a text file with each cell, stimuli presented, other stuff. It would be nice to have it formatted in such a way that it can be used to analyze data.

to append to an existing cell list, we could have a dropdown menu of existing cell lists. Not sure where this would live.

djtools.GaussSmooth(spiketimes, sigma, xlimits)#

usage: [t, fr]=GaussSmooth(spiketimes, sigma, xlimits) smooths a spiketrain by gaussian convolution inputs:

spiketimes: a list of spiketimes, in ms, relative to stimulus onset

(e.g. [75.2406 -15.4977 176.7524 49.1524 … ])

sigma: standard deviation of gaussian kernel, in ms xlimits: xlimits for time vector, in ms

outputs:

t: time vector for smoothed firing rate, in ms fr: smoothed firing rate, in Hz

for example, you could plot(t, fr); xlabel(‘time, ms’); ylabel(‘firing rate, Hz’)

djtools.GetEventsAndSCT_Timestamps(messages, sampleRate, all_channels_timestamps, all_channels_data, all_channels_info, stimlog)#
djtools.GetNetworkEvents(filename)#

reads open ephys network events messages from messages.events file

djtools.GetParamStr(stimulus)#

utility function to generate standardized param strings to use when making stimulus protocols note that there is a 255 character limit to the entire emssage string, so we will employ some shorthand as needed

djtools.GetPlottingFunction(varargin)#

tries to figure out which plotting function is appropriate for some djmaus data Assume that we want the PSTH version (should be straightforward to plot LFPs instead if desired)

usage: PlottingFunction=GetPlottingFunction([datadir]) defaults to current directory

djtools.GetStimParams(varargin)#

usage: stimparams=GetStimParams(datapath)

returns structure with stimulus params for stimuli that were presented for that data session

djtools.HistISI(T, varargin)#
H = HistISI(TS, parameters)

H = HistISI(TS, ‘maxLogISI’,’maxLogISI’,5) for fixed upper limit 10^5 msec (or 100 sec)

INPUTS:

TS = a single ts object

OUTPUTS:

H = histogram of ISI N = bin centers

Parameters
  • 500 (nBins) –

  • variable (maxLogISI) –

  • minLogISI

If no outputs are given, then plots the figure directly.

ADR 1998 version L5.3 RELEASED as part of MClust 2.0 See standard disclaimer in Contents.m

Status: PROMOTED (Release version) See documentation for copyright (owned by original authors) and warranties (none!). This code released as part of MClust 3.0. Version control M3.0.

ADR 2 DEC 2003 fixed capitalizations

Assumes data passed in are in seconds.

djtools.JustPlotIt(varargin)#

tries to figure out the appropriate way to plot the data in a data directory, and does it. For djmaus/open-ephys data.

usage: JustPlotIt([datapath], [other parameters])

defaults to current directory if you include a list of other parameters (like xlimits, tetrode number, etc) they will get passed on to the appropriate function. They have to be in the right order for that function.

djtools.KSDirListBuilder(varargin)#
A GUI for building a list of kilosort master data directories

we don’t add invidual cells, just the master data directory for each recording session. it has a button to add current directory to the list another button that opens a dialog box so you can browse to the desired directory

what does it do? It creates/appends a machine readable cell list as a .txt file

mw 3.14.2019

djtools.KS_PlotGPIAS_PSTH(varargin)#

plots clustered spiking GPIAS data from djmaus

usage: PlotGPIAS_PSTH([datapath], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) (all inputs are optional)

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-1.5*max(gapdurs) 2*soa]; ylimits defaults to an autoscaled value

tetrode number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.KS_PlotGPIAS_PSTH_single(varargin)#

plots a single file of clustered spiking GPIAS data from djmaus

usage: PlotGPIAS_PSTH(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.KS_ProcessGPIAS_PSTH_single(varargin)#

processes a single file of kilosrt clustered spiking GPIAS data from djmaus

usage: KS_ProcessGPIAS_PSTH_single(datadir, filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-1.5*max(gapdurs) 2*soa] saves to outfile

djtools.Make2ToneWNProtocol(freqsperoctave, minfreq, maxfreq, numamplitudes, minamplitude, maxamplitude, include_whitenoise, duration, ramp, isi, nrepeats, numprobeamplitudes, minprobeamplitude, maxprobeamplitude, numSOA, minSOA, maxSOA, interleave_laser, include_silent_sound)#
usage: Make2ToneProtocol(freqsperoctave, minfreq, maxfreq, numamplitudes, …

minamplitude, maxamplitude, include_whitenoise, duration, ramp, isi, nrepeats, probefreq, numprobeamplitudes, … minprobeamplitude, maxprobeamplitude, numSOA, minSOA, maxSOA, interleave_laser, include_silent_sound)

modified from Make2ToneProtocol to use WN only (Make2ToneProtocol does not allow WN) mw 10.30.2015

creates an djmaus stimulus protocol file for a 2 tone protocol stimulus with probe tones of single frequency but multiple amplitudes no white noise used

inputs: freqsperoctave: number of frequencies per octave (frequency resolution) minfreq: lowest frequency in Hz maxfreq: highest frequency in Hz

note: if minfreq-to-maxfreq cannot be divided evenly into freqsperoctave, the nearest maxfreq will be used (i.e. the requested freqsperoctave will be exactly enforced)

numamplitudes: number of masker amplitude steps minamplitude: maximum masker amplitude in dB SPL (requires system to be calibrated) maxamplitude: maximum masker amplitude in dB SPL (requires system to be calibrated) include_whitenoise: 1 for yes and 0 for no duration: masker duration in ms ramp: on-off ramp duration in ms isi: inter stimulus interval (onset-to-onset) in ms nrepeats: number of repetitions (different pseudorandom orders) numprobeamplitudes: number of probe tone amplitude steps minprobeamplitude: minimum probe tone amplitude in dB SPL maxprobeamplitude: maximum probe tone amplitude in dB SPL numSOA: number of Stimulus Onset Asynchrony in ms = time between masker onset and probe tone onset minSOA: the shortest SOA maxSOA: the longest SOA

interleave_laser: 1 for yes and 0 for no, x2 nreps with randomly inserted include_silent_sound: 0 or 1 to include an extra stimulus that is silent,

useful for explicitly collecting spontaneous and/or laser-only trials as a separate condition

laser trials

djtools.Make2toneProtocol(masker_freqsperoctave, masker_minfreq, masker_maxfreq, masker_numamps, masker_minamp, masker_maxamp, masker_durs, probe_freqsperoctave, probe_minfreq, probe_maxfreq, probe_numamps, probe_minamp, probe_maxamp, probe_durs, SOAs, ramp, iti, laser, include_WN, include_silentsound, nrepeats)#

for djmaus use Make2toneProtocol(masker_freqsperoctave, masker_minfreq, masker_maxfreq, masker_numamps, masker_minamp, masker_maxamp, masker_durs … probe_freqsperoctave, probe_minfreq, probe_maxfreq, probe_numamps, probe_minamp, probe_maxamp, probe_durs, SOAs, ramp, itis, laser, incluse_WN, include_silent_sound, nrepeats) SOAs (ms) from onset of masker to onset of probe itis (ms) from onset of masker to onset of the second masker (i think), freqs are in Hz, amps are in dB if laser=1 will interleave all stimuli including silentsound silentsound will be an average of masker + probe + SOAs duration creates probe alone stimuli as well recommend to only vary one parameter (either dur or freq or amp) varying more than one will make the protocol very long

Make2toneProtocol(1, 200, 12000, 1, 80, 80, [10 25 50], 1, 6000, 6000, 1, 70, 70, 30, [50 80 100], 5, 1000, 1, 1, 1, 30) = 142 min

ira 12.06.17

djtools.Make2toneProtocol_4Yashar#

this was written to make stimuli for Yashar. It creates white noise bursts and laser pulses, not interleaved. ira 12.05.17

djtools.MakeAMNoisedjProtocol(modulation_rates, modulation_depth, amplitude, duration, next, ramp, nrepeats)#

usage: MakeAMNoisejProtocol(modulation_rates, modulation_depth, amplitude, duration, isi, ramp, nrepeats)

inputs:

modulation_rates - vector of modulation rates (Hz) modulation_depth - modulation depth (0-100%) duration - overall stimulus duration (ms) amplitude - amplitude (dB) isi - inter stimulus interval (ms) ramp - inter stimulus interval (ms) nrepeats - number of repeats

outputs:
  • creates a suitably named stimulus protocol in djprefs.stimuli/AMProtocols

example calls:

modulation_rates =[1 2 4 8 16 32 64 128 256]; modulation_depth=100; duration =2000; amplitude=80; next=1000; ramp=10; nrepeats=20; MakeAMNoisedjProtocol(modulation_rates, modulation_depth, amplitude, duration, next, ramp, nrepeats)

djtools.MakeAsymGPIASdjProtocol(noiseamp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamp, soa, soaflag, pulseramp, gapramps, isi, isi_var, interleave_laser, nrepeats)#
usage MakeAsymGPIASdjProtocol(noiseamp, gapdurs, gapdelay, post_startle_duration,

pulsedur, pulseamp, soa, soaflag, ramp, iti, iti_var, interleave_laser, nrepeats)

creates a djmaus stimulus protocol file for Asymmetrical GPIAS (gap-induced pre-pulse inhibition of acoustic startle response). can use multiple gap durations, gap is silent using variable ITI. What is an Asymmetric GPIAS? The gap ramps are specified individually. The offramp is the noise offset ramp (start of gap). The onramp is the noise onset (gap termination). Note that the conventional GPIAS stimuli always have gap ramp of zero. Note that the continuous background noise has ramps fixed at zero (which is required if they are to be continuous). The ramps are centered on gap transitions. In other words, the background noise starts changing half-ramp before and stops changing half-ramp after each transition. This protocol is designed such that you provide a list of gap ramps (such as [0 5 10]), and the on and off ramps take each possible combination of these values. You could design it differently, all you need to do is specify what on & off ramps you want MakeAsymGPIAS to use.

recent edits:

-updated to djmaus version 9-2016 -added interleave_laser flag (0 or 1), so output can be already

laser-interleaved (no need for an extra ppalaser step) 9-2016

-changed to use whitenoise instead of band-passed noise. 9-2016 -added soaflag to specify whether soa is ‘soa’ or ‘isi’ -changed gapdelay to specify time to gap offset instead of gap onset (so

that ppalaser comes on relative to gap offset in the ‘isi’ case) (note: this is actually implemented in MakeGPIAS)

-introduced asymmetric ramps -only one pulseamp allowed in this protocol builder

mw 10.11.2014

Note

inputs: gapramps: list of ramps for gap onset and termination, in ms noiseamp: amplitude of the continuous white noise, in dB SPL gapdurs: durations of the pre-pulse gap, in ms, in a vector, e.g. 50, or [0 50] gapdelay: delay from start of continuous noise to gap OFFSET, in ms post_startle_duration: duration of noise to play after the startle

stimulus has finished. We added this Oct 14, 2013 to allow extra time for laser be on after the startle.

pulsedur: duration of the startle pulse in ms (can be 0 for no startle) pulseamp: amplitude of the startle pulse in dB SPL, only one value allowed here soa: Stimulus Onset Asynchrony in ms = time between gap onset and

startle pulse tone onset

soaflag: can be either ‘soa’ (default), in which case soa value specifies the time between the onset of the gap and the onset of the startle, or else ‘isi’, in which case soa specifies the time between gap offset and startle onset. If anything other than ‘isi’ it will default to ‘soa’. pulseramp: startle pulse on-off ramp duration in ms iti: inter trial interval (onset-to-onset) in ms iti_var: fractional variability of iti. Use 0 for fixed iti, or e.g. 0.1 to have iti vary by up to +-10% interleave_laser: 0 or 1 to duplicate all stimuli and interleave laser

and non-laser trials in random order

nrepeats: number of repetitions (different pseudorandom orders)

note: still using the variable isi for inter-trial interval, AKA iti outputs: creates a suitably named stimulus protocol in D:labexper2.2protocolsASR Protocols

Note that the ITI between GPIAS stimuli cannot be less than gapdelay+poststartle, and can only vary by increments of this duration.

example calls:

fixed iti of 10 seconds with interleaved laser:

MakeGPIASdjProtocol(80, [0 2 4 6], 1000, 1000, 25, 100, 60, ‘soa’, 0, 10e3, 0, 1, 5)

iti ranging from 10s to 20s (15 s on average)

brief variable duration gaps, 60ms SOA MakeGPIASdjProtocol(80, [0 2 4 6], 1000, 1000, 25, 100, 60, ‘soa’, 0, 15e3, .33, 1, 15)

brief gap, no startle, ability to deliver a long (1sec) laser pulse beyond startle offset time MakeGPIASdjProtocol(80, [10], 1000, 1000, 0, 100, 60, ‘soa’, 0, 15e3, .33, 1, 20)

MakeGPIASdjProtocol(80, [0 1 2 4 8 16 32 64 128 256], 1000, 1000, 0, 100, 50, ‘isi’, 0, 1e3, 0, 0, 15)

noiseamp=80; gapdurs=[16 128 ]; gapdelay=1000; poststartle=1000; gapramps=[0 4 8] pulsedur=0; pulseamp=0; soa=50; soaflag=’isi’; pulseramp=0; isi=1000; isi_var=0; IL=0; nreps=50; MakeAsymGPIASdjProtocol(noiseamp, gapdurs, gapdelay, poststartle, pulsedur, pulseamp, soa, soaflag, pulseramp, gapramps, isi, isi_var, IL, nreps)

djtools.MakeClicktraindjProtocol(amplitude, trainduration, icis, clickduration, next, ramp, nrepeats)#

usage: MakeClicktraindjProtocol(amplitude, trainduration, icis, clickduration, next, ramp, nrepeats)

modified from MakeWNTrainProtocol2, and ported to djmaus we have a single amplitude and a fixed train duration (with variable number of clicks per train) creates an djmaus protocol file for a train of white noise bursts (click train)

inputs:

amplitude: amplitude in dB SPL (requires system to be calibrated) trainduration - duration of train, in ms icis - inter-click interval, i.e. interval between the

start of previous click and start of the next click (use an array for multiple ICIs)

clickduration - duration of an individual click (ms) next - inter-click-train-interval, i.e. when the next

click train should follow the previous one (ms)

ramp - rising/falling edge of individual clicks (can be zero) nrepeats: number of repetitions (different pseudorandom orders)

outputs:
  • creates a suitably named stimulus protocol in djprefs.stimuli/ClicktrainProtocols

example calls: MakeClicktraindjProtocol(80, 10e3, [1 2 4 8 16 32 64 128 256], .5, 3000, 0, 20) MakeClicktraindjProtocol(70, 2e3, [1 2 4 8 16 32 64 128 256], .5, 3000, 0, 20)

djtools.MakeF1F2GapProtocol(F1, F2, amplitude, include_whitenoise, duration, ramp, iti, nrepeats, gapdurs, include_silent_sound)#
usage: MakeF1F2GapProtocol(f1, f2, amplitude, …

include_whitenoise, duration, ramp, iti, nrepeats, gapdurs, include_silent_sound)

mw 3.6.2017

creates a djmaus stimulus protocol file for a 2 tone gap stimulus with an F1 frequency tone followed by a gap and then a F2 frequency tone the combinations of F1-F1, F2-F2, F1-F2, and F2-F1 are used this is designed for a specific experiment in which F1 evokes ON response only, and F2 evokes OFF response only

inputs: F1, F2: tone frequencies in Hz amplitude: we used one fixed amplitude in dB SPL include_whitenoise: 1 for yes and 0 for no duration: tone duration in ms ramp: on-off ramp duration in ms iti: inter trial interval in ms nrepeats: number of repetitions (different pseudorandom orders) gapdurs: the duration of gaps between F1 and F2 include_silent_sound: 0 or 1 to include an extra stimulus that is silent,

useful for explicitly collecting spontaneous and/or laser-only trials as a separate condition

outputs: creates a suitably named stimulus protocol in home/lab/djmaus/stimuli/2Tone

example calls: 500 ms tones with 16 and 128 ms gaps, no WN or silent sound

F1=4000; F2=10000; amplitude=70; include_whitenoise=1; duration=500; ramp=3; iti=1000; nrepeats=20; gapdurs=[16 128]; include_silent_sound=0; MakeF1F2GapProtocol(F1, F2, amplitude, include_whitenoise, duration, ramp, iti, nrepeats, gapdurs, include_silent_sound)

djtools.MakeF1F2GapProtocol2(F1, F2, amplitude, include_whitenoise, duration, ramp, iti, nrepeats, gapdurs, include_silent_sound)#
same as MakeF1F2GapProtocol, but only presents the single F1-F2

combination. This will allow efficient collection of many gap durs, but must be run in conjunction with a normal F1F2GapProtocol so that we get all the F1 and F2 combinations at 2 key gapdurs

usage: MakeF1F2GapProtocol2(f1, f2, amplitude, …

include_whitenoise, duration, ramp, iti, nrepeats, gapdurs, include_silent_sound)

mw 3.6.2017

creates a djmaus stimulus protocol file for a 2 tone gap stimulus with an F1 frequency tone followed by a gap and then a F2 frequency tone the combinations of F1-F1, F2-F2, F1-F2, and F2-F1 are used this is designed for a specific experiment in which F1 evokes ON response only, and F2 evokes OFF response only

inputs: F1, F2: tone frequencies in Hz amplitude: we used one fixed amplitude in dB SPL include_whitenoise: 1 for yes and 0 for no duration: tone duration in ms ramp: on-off ramp duration in ms iti: inter trial interval in ms nrepeats: number of repetitions (different pseudorandom orders) gapdurs: the duration of gaps between F1 and F2 include_silent_sound: 0 or 1 to include an extra stimulus that is silent,

useful for explicitly collecting spontaneous and/or laser-only trials as a separate condition

outputs: creates a suitably named stimulus protocol in home/lab/djmaus/stimuli/2Tone

example calls: 500 ms tones with 16 and 128 ms gaps, no WN or silent sound

F1=4000; F2=10000; amplitude=70; include_whitenoise=0; duration=500; ramp=2; iti=1000; nrepeats=20; gapdurs=[2 4 8 16 32 64 128 256]; include_silent_sound=0; MakeF1F2GapProtocol2(F1, F2, amplitude, include_whitenoise, duration, ramp, iti, nrepeats, gapdurs, include_silent_sound)

djtools.MakeFlashtraindjProtocol(trainduration, icis, flashduration, next, nrepeats)#

usage: MakeFlashtraindjProtocol(trainduration, icis, flashduration, next, nrepeats)

% creates an djmaus protocol file for flash trains of desired rate/duration. No sound. modified from MakeClicktraindjProtocol - designed to mimic it optogenetically uses fixed train duration (with variable number of flashes per train)

inputs:

trainduration - duration of train, in ms icis - inter-flash interval, i.e. interval between the

start of previous flash and start of the next flash (use an array for multiple ICIs)

flashduration - duration of an individual flash (ms) next - inter-flash-train-interval, i.e. when the next

flash train should follow the previous one (ms)

nrepeats: number of repetitions (different pseudorandom orders)

outputs:
  • creates a suitably named stimulus protocol in djprefs.stimuli/ClicktrainProtocols

example calls: MakeFlashtraindjProtocol(2e3, [1 2 4 8 16 32 64 128 256], .5, 2000, 20)

djtools.MakeGPIASLaserPulseProtocol(Laserstarts, Laserpulsewidth, Lasernumpulses, Laserisi, noiseamp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamp, soa, soaflag, ramp, isi, isi_var, nrepeats)#
usage MakeGPIASLaserPulseProtocol(Laserstart, Laserpulsewidth, Lasernumpulses, Laserisi, noiseamp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamp, soa, soaflag, …

ramp, isi, isi_var, nrepeats)

creates a djmaus stimulus protocol file for GPIAS (gap-induced pre-pulse inhibition of acoustic startle response). can use multiple gap durations, gap is silent, can use variable ITI.

this version randomly interleaves trials with a laser pulse for each GPIAS trial,

the parameters are set by the first arguments (Laserstarts, Laserpulsewidth, Lasernumpulses, Laserisi)

Laserstarts can be an array, the other laser params should be single values

example call

Laserstarts=[0 25]; Laserpulsewidth=5; Lasernumpulses=1; Laserisi=0; noiseamp=80; gapdurs=[0 32]; gapdelay=500; poststartle=500; pulsedur=25; pulseamp=100; soa=50; soaflag=’isi’; ramp=0; isi=12000; isi_var=0; nrepeats=20;

MakeGPIASLaserPulseProtocol(Laserstarts, Laserpulsewidth, Lasernumpulses, Laserisi, noiseamp, gapdurs, gapdelay, poststartle, pulsedur, pulseamp, soa, soaflag, ramp, isi, isi_var, nrepeats)

djtools.MakeGPIASdjProtocol(noiseamp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamps, soa, soaflag, ramp, isi, isi_var, interleave_laser, nrepeats)#
usage MakeGPIASdjProtocol(noiseamp, gapdurs, gapdelay, post_startle_duration,

pulsedur, pulseamps, soa, soaflag, ramp, iti, iti_var, interleave_laser, nrepeats)

creates a djmaus stimulus protocol file for GPIAS (gap-induced pre-pulse inhibition of acoustic startle response). can use multiple gap durations, gap is silent using variable ITI.

recent edits:

-updated to djmaus version 9-2016 -added interleave_laser flag (0 or 1), so output can be already

laser-interleaved (no need for an extra ppalaser step) 9-2016

-changed to use whitenoise instead of band-passed noise. 9-2016 -added soaflag to specify whether soa is ‘soa’ or ‘isi’ -changed gapdelay to specify time to gap offset instead of gap onset (so

that ppalaser comes on relative to gap offset in the ‘isi’ case) (note: this is actually implemented in MakeGPIAS)

Note that GPIAS stimuli always have gap ramp of zero. Note that the continuous background noise now has ramps fixed at zero (which is required if they are to be continuous).

mw 10.11.2016

Note

inputs: noiseamp: amplitude of the continuous white noise, in dB SPL gapdurs: durations of the pre-pulse gap, in ms, in a vector, e.g. 50, or [0 50] gapdelay: delay from start of continuous noise to gap OFFSET, in ms post_startle_duration: duration of noise to play after the startle

stimulus has finished. We added this Oct 14, 2013 to allow extra time for laser be on after the startle.

pulsedur: duration of the startle pulse in ms (can be 0 for no startle) pulseamps: amplitudes of the startle pulse in dB SPL, in a vector, e.g. 95, or [90 95 100] soa: Stimulus Onset Asynchrony in ms = time between gap onset and

startle pulse tone onset

soaflag: can be either ‘soa’ (default), in which case soa value specifies the time between the onset of the gap and the onset of the startle, or else ‘isi’, in which case soa specifies the time between gap offset and startle onset. If anything other than ‘isi’ it will default to ‘soa’. ramp: on-off ramp duration in ms iti: inter trial interval (onset-to-onset) in ms iti_var: fractional variability of iti. Use 0 for fixed iti, or e.g. 0.1 to have iti vary by up to +-10% interleave_laser: 0 or 1 to duplicate all stimuli and interleave laser

and non-laser trials in random order

nrepeats: number of repetitions (different pseudorandom orders)

note: still using the variable isi for inter-trial interval, AKA iti outputs: creates a suitably named stimulus protocol in D:labexper2.2protocolsASR Protocols

example calls:

fixed iti of 15 seconds with interleaved laser:

MakeGPIASdjProtocol(80, [0 16], 1000, 1000, 25, 100, 50, ‘isi’, 0, 15e3, 0.33, 1, 5)

iti ranging from 10s to 20s (15 s on average)

brief variable duration gaps, 60ms SOA MakeGPIASdjProtocol(80, [0 2 4 6], 1000, 1000, 25, 100, 60, ‘soa’, 0, 15e3, .33, 1, 15)

brief gap, no startle, ability to deliver a long (1sec) laser pulse beyond startle offset time MakeGPIASdjProtocol(80, [10], 1000, 1000, 0, 100, 60, ‘soa’, 0, 15e3, .33, 1, 20)

MakeGPIASdjProtocol(80, [0 1 2 4 8 16 32 64 128 256], 1000, 1000, 0, 100, 50, ‘isi’, 0, 2e3, 0, 1, 15)

noiseamp=80; gapdurs=[0 32]; gapdelay=1000; poststartle=1000; pulsedur=25; pulseamps=100; soa=50; soaflag=’isi’; ramp=0; isi=15000; isi_var=.33; IL=1; nreps=10; MakeGPIASdjProtocol(noiseamp, gapdurs, gapdelay, poststartle, pulsedur, pulseamps, soa, soaflag, ramp, isi, isi_var, IL, nreps)

djtools.MakeGPIASflashtrainProtocol(VarLaserpulsewidths, noiseamp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamp, soa, soaflag, ramp, isi, isi_var, nrepeats)#
usage MakeGPIASflashtrainProtocol(VarLaserpulsewidths, noiseamp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamp, soa, soaflag, …

ramp, isi, isi_var, nrepeats)

creates a djmaus stimulus protocol file for GPIAS (gap-induced pre-pulse inhibition of acoustic startle response). can use multiple gap durations, gap is silent using variable ITI.

this version randomly interleaves trials with a laser pulse for each GPIAS trial,

the laser is on for 50 ms post-gap interval

VarLaserpulsewidths is an array of laser pulsewidths used to control laser “power”

example call

VarLaserpulsewidths=[.1 .5 1 2 3 4 5 ]; noiseamp=80; gapdurs=[0 32]; gapdelay=500; poststartle=500; pulsedur=0; pulseamp=100; soa=50; soaflag=’isi’; ramp=0; isi=500; isi_var=0; nrepeats=40; MakeGPIASflashtrainProtocol(VarLaserpulsewidths, noiseamp, gapdurs, gapdelay, poststartle, pulsedur, pulseamp, soa, soaflag, ramp, isi, isi_var, nrepeats)

djtools.MakeGapShockdjProtocol()#

usage: MakeGapShockdjProtocol Create Gap Shock Protocol and incorporate a previously

created GPIAS djmaus protocol. Laser and Shock are now independent channels. last updated by Mike 8-24-2017

This is a special-purpose protocol for paired gap-shock conditioning. First use MakeGPIASdjProtocol to create a GPIAS protocol. Use IL=0.

Then call this function and select that protocol to add a laser and shock condition to every GPIAS trial. Use the shock soundcard channel output to drive the S88 stimulator to deliver shock. The soundcard channel used for shock is specified in djPrefs - you might need to edit your djPrefs the first time you try this on a new computer, and add the following line: pref.Shockchannel=5; %or whatever channel you have available

New: in principle you can include whatever type of laser conditions you want. For this version we hard-code every trial to have both a shock and a laser. Slight modification of this function should allow any combination.

Example

noiseamp=80; gapdurs=16; gapdelay=1000; poststartle=1000; pulsedur=0;pulseamps=0;soa=50; soaflag=’isi’; ramp=0; isi=30000; isi_var=.33; IL=0; nreps=30; MakeGPIASdjProtocol(noiseamp, gapdurs, gapdelay, poststartle, pulsedur, pulseamps, soa, soaflag, ramp, isi, isi_var, IL, nreps) MakeGPIASdjProtocol(80, 16, 1000, 1000, 0, 100, 50, iti, 0, 30000, .33, 0, 30) MakeGapShockdjProtocol

djtools.MakePIMPProtocol(varargin)#

takes an existing protocol and inserts N laser pulses randomly, specify N

djtools.MakePINPProtocol_fromStim(varargin)#

takes an existing protocol and inserts N laser pulses randomly, specify N only have to specify how many silent laser pulses to insert, will split them and insert them throughout the stimulus protocol works with tuning curves and wn stimuli only ira 04.18.2017

djtools.MakePINPdjProtocol(flashduration, next, nrepeats)#

usage: MakePINPdjProtocol(trainduration, icis, flashduration, next, nrepeats)

% creates an djmaus protocol file for PINPing. This consists only of silent sounds, with interleaved laser pulses. There are also some flashtrains included to test for reliability.

djtools.MakePPIdjProtocol(prepulsedurs, prepulseamps, pulsedur, pulseamp, soa, soaflag, ramp, iti, iti_var, interleave_laser, post_startle_duration, nrepeats)#
usage: MakePPIdjProtocol(prepulsedurs, prepulseamps, pulsedur, pulseamp, soa, soaflag, …

ramp, iti, iti_var, interleave_laser, post_startle_duration, nrepeats)

creates a djmaus stimulus protocol file for PPI (pre-pulse inhibition of acoustic startle response). Pre-pulse and startle pulse are both white noise. Can use multiple pre-pulse durations and amplitudes. You can only use a single startle pulse duration and amplitude.

automatically includes a silent pre-pulse (-1000 dB) to provide a pure-startle condition for comparison. If you don’t want this, you can set a flag below. If you request a -1000 dB or 0 ms prepulseamp it will not be duplicated.

mw 08.16.2021

Note

inputs: prepulseamps: amplitudes of the pre-pulse, in dB, in a vector, e.g. 60, or [40 50 60] prepulsedurs: durations of the pre-pulse, in ms, in a vector, e.g. 50, or [0 50] pulsedur: duration of the startle pulse in ms (can be 0 for no startle) pulseamp: amplitude of the startle pulse in dB SPL soa: Stimulus Onset Asynchrony in ms = time between prepulse onset and

startle pulse onset

soaflag: can be either ‘soa’ (default), in which case soa value specifies the time between the onset of the prepulse and the onset of the startle pulse, or else ‘isi’, in which case soa specifies the time between prepulse offset and startle onset. If anything other than ‘isi’ it will default to ‘soa’. ramp: onset and offset ramp duration in ms, used for both prepulse and startle iti: inter trial interval (onset-to-onset) in ms iti_var: fractional variability of iti. Use 0 for fixed iti, or e.g. 0.1 to have iti vary by up to +-10% interleave_laser: 0 or 1 to duplicate all stimuli and interleave laser

and non-laser trials in random order

post_startle_duration: duration of silence to play after the startle

stimulus has finished. We added this to allow extra time for laser be on after the startle.

nrepeats: number of repetitions (different pseudorandom orders)

outputs: creates a suitably named stimulus protocol in djmaus/stimuli/PPI Protocols returns filename and path so you could programmatically create and use a protocol

example calls:

prepulsedurs=25; prepulseamps = 60; pulsedur=25; pulseamp=100; soa = 75; soaflag=’soa’; ramp=0; iti=15000; iti_var=0; interleave_laser=0; nrepeats=10; post_startle_duration=0; MakePPIdjProtocol(prepulsedurs, prepulseamps, pulsedur, pulseamp, soa, soaflag, ramp, iti, iti_var, interleave_laser, post_startle_duration, nrepeats)

djtools.MakeShockProtocol()#
djtools.MakeSingleLaserFlagProtocol()#

simple function to creat a protocol with a single laser flag the idea is that you use djmaus front panel to specifiy laser params, and the play button to control timing

djtools.MakeSoundfileSeamlessdjProtocol(amplitude, dur, include_whitenoise, interleave_laser, include_silent_sound, isi, nrepeats)#
Usage: MakeSoundfileSeamlessdjProtocol(amplitude, dur, include_whitenoise, …

interleave_laser, include_silent_sound, isi, nrepeats)

modified by Kip (3/31/21) to make seamless version of MakeSoundfiledjProtocol

loads sounds from sound files (e.g., WAV files). Opens a dialog box for you to select the sound files and provide a descriptive name for the protocol.

see help audioread for list of supported file formats. WAV works for sure. if stereo only the right channel will be used

INPUTS: amplitude: in dB SPL. All sounds will be normalized to peak level across all sounds,

then scaled to this amplitude

duration (in ms): how much of the soundfile to use

(use [] to default to total duration of the soundfile)

include_whitenoise: 0 or 1 to include white noise bursts (at amplitude) interleave_laser: 0 or 1 to duplicate all stimuli and interleave laser

and non-laser trials in random order

include_silent_sound: 0 or 1 to include an extra stimulus that is silent,

useful for explicitly collecting spontaneous and/or laser-only trials as a separate condition

isi: inter stimulus interval (onset-to-onset) in ms nrepeats: number of repetitions (different pseudorandom orders) OUTPUTS:

  • creates a suitably named stimulus protocol in djprefs.stimuliSoundfile Protocols

  • copies resampled/truncated/amplitude-adjusted sourcefiles to subfolder

  • returns name & path to protocol (AKH 6/19/13)

example call: amp= 80; dur=[]; include_whitenoise= 0; interleave_laser= 0; include_silent_sound= 0; isi= 800; nrepeats= 20;

MakeSoundfiledjProtocol(amp, dur, include_whitenoise, interleave_laser, include_silent_sound, isi, nrepeats)

djtools.MakeSoundfiledjProtocol(amplitude, dur, include_whitenoise, interleave_laser, include_silent_sound, isi, nrepeats)#
Usage: MakeSoundfiledjProtocol(amplitude, dur, include_whitenoise, …

interleave_laser, include_silent_sound, isi, nrepeats)

loads sounds from sound files (e.g., WAV files). Opens a dialog box for you to select the sound files and provide a descriptive name for the protocol.

see help audioread for list of supported file formats. WAV works for sure. if stereo only the right channel will be used

INPUTS: amplitude: in dB SPL. All sounds will be normalized to peak level across all sounds,

then scaled to this amplitude

duration (in ms): how much of the soundfile to use

(use [] to default to total duration of the soundfile)

include_whitenoise: 0 or 1 to include white noise bursts (at amplitude) interleave_laser: 0 or 1 to duplicate all stimuli and interleave laser

and non-laser trials in random order

include_silent_sound: 0 or 1 to include an extra stimulus that is silent,

useful for explicitly collecting spontaneous and/or laser-only trials as a separate condition

isi: inter stimulus interval (onset-to-onset) in ms nrepeats: number of repetitions (different pseudorandom orders) OUTPUTS:

  • creates a suitably named stimulus protocol in djprefs.stimuliSoundfile Protocols

  • copies resampled/truncated/amplitude-adjusted sourcefiles to subfolder

  • returns name & path to protocol (AKH 6/19/13)

example call: amp= 80; dur=[]; include_whitenoise= 0; interleave_laser= 0; include_silent_sound= 0; isi= 800; nrepeats= 20;

MakeSoundfiledjProtocol(amp, dur, include_whitenoise, interleave_laser, include_silent_sound, isi, nrepeats)

djtools.MakeSustainedSuppressionProtocol(duration, next, nrepeats)#

% creates a specific djmaus protocol file for validating sustained flashtrain suppression. In behavior we have the arduino flashing the laser continuously (5ms on- 5ms off) for 100 seconds, or longer. We just want to validate the electrophysiological effect of that.

djtools.MakeToneAutopilotProtocol(freqsperoctave, minfreq, maxfreq, numamplitudes, minamplitude, maxamplitude, durations, ramp, include_whitenoise, isi)#
Usage: [filename,path]=MakeToneAutopilotProtocol(freqsperoctave, …

minfreq, maxfreq, numamplitudes, … minamplitude, maxamplitude, durations, ramp, include_whitenoise,… isi)

like as MakeTonedjProtocol but makes an autopilot protocol

INPUTS: freqsperoctave: number of frequencies per octave (frequency resolution) minfreq: lowest frequency in Hz maxfreq: highest frequency in Hz

note: if minfreq-to-maxfreq cannot be divided evenly into freqsperoctave, the nearest maxfreq will be used (i.e. the requested freqsperoctave will be exactly enforced)

numamplitudes: number of amplitude steps minamplitude: maximum amplitude in dB SPL (requires system to be calibrated) maxamplitude: maximum amplitude in dB SPL (requires system to be calibrated) durations: vector of different tone durations (in ms) (can be a single duration) ramp: on-off ramp duration in ms include_whitenoise: 0 or 1 to include white noise bursts at each amplitude isi: inter stimulus interval (onset-to-onset) in ms OUTPUTS:

  • creates a suitably named stimulus protocol in djprefs.stimuliTone Protocols

  • returns name & path to protocol (AKH 6/19/13)

freqsperoctave= 1; minfreq= 2e3; maxfreq= 4e3; numamplitudes= 1; minamplitude= .05; maxamplitude= .05; durations= 100; ramp=3; include_whitenoise= 0; isi= 500; MakeToneAutopilotProtocol(freqsperoctave, minfreq, maxfreq, numamplitudes, minamplitude, maxamplitude, durations, ramp, include_whitenoise, isi)

to include only whitenoise, use freqsperoctave==0 & minfreq==0 & maxfreq==0 & include_whitenoise==1

djtools.MakeToneGPIASdjProtocol(carrier_freq, carrier_amp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamps, soa, soaflag, ramp, isi, isi_var, interleave_laser, nrepeats)#
usage MakeToneGPIASdjProtocol(carrier_freq, carrier_amp, gapdurs, gapdelay, post_startle_duration,

pulsedur, pulseamps, soa, soaflag, ramp, iti, iti_var, interleave_laser, nrepeats)

creates a djmaus stimulus protocol file for pure-tone carrier GPIAS (gap-induced pre-pulse inhibition of acoustic startle response). can use multiple gap durations, gap is silent using variable ITI.

recent edits:
modifed from MakeGPIASdjProtocol to use tone carrier and include ramps

mw 9.13.2018

-updated to djmaus version 9-2016 -added interleave_laser flag (0 or 1), so output can be already

laser-interleaved (no need for an extra ppalaser step) 9-2016

-added soaflag to specify whether soa is ‘soa’ or ‘isi’ -changed gapdelay to specify time to gap offset instead of gap onset (so

that ppalaser comes on relative to gap offset in the ‘isi’ case) (note: this is actually implemented in MakeGPIAS)

Note that the continuous background noise now has ramps fixed at zero (which is required if they are to be continuous).

mw 10.11.2016

inputs: carrier_freq: frequency of the tone carrier, in Hz carrier_amp: amplitude of the tone carrier, in dB SPL gapdurs: durations of the pre-pulse gap, in ms, in a vector, e.g. 50, or [0 50] gapdelay: delay from start of continuous noise to gap OFFSET, in ms post_startle_duration: duration of noise to play after the startle

stimulus has finished. We added this Oct 14, 2013 to allow extra time for laser be on after the startle.

pulsedur: duration of the startle pulse in ms (can be 0 for no startle) pulseamps: amplitudes of the startle pulse in dB SPL, in a vector, e.g. 95, or [90 95 100] soa: Stimulus Onset Asynchrony in ms = time between gap onset and

startle pulse tone onset

soaflag: can be either ‘soa’ (default), in which case soa value specifies the time between the onset of the gap and the onset of the startle, or else ‘isi’, in which case soa specifies the time between gap offset and startle onset. If anything other than ‘isi’ it will default to ‘soa’. ramp: on-off ramp duration in ms iti: inter trial interval (onset-to-onset) in ms iti_var: fractional variability of iti. Use 0 for fixed iti, or e.g. 0.1 to have iti vary by up to +-10% interleave_laser: 0 or 1 to duplicate all stimuli and interleave laser

and non-laser trials in random order

nrepeats: number of repetitions (different pseudorandom orders)

note: still using the variable isi for inter-trial interval, AKA iti outputs: creates a suitably named stimulus protocol in D:labexper2.2protocolsASR Protocols

example calls:

fixed iti of 15 seconds with interleaved laser:

MaketoneGPIASdjProtocol(8000, 80, [0 16], 1000, 1000, 25, 100, 50, ‘isi’, 0, 15e3, 0.33, 1, 5)

iti ranging from 10s to 20s (15 s on average)

brief variable duration gaps, 60ms SOA MaketoneGPIASdjProtocol(8000, 80, [0 2 4 6], 1000, 1000, 25, 100, 60, ‘soa’, 0, 15e3, .33, 1, 15)

brief gap, no startle, ability to deliver a long (1sec) laser pulse beyond startle offset time MaketoneGPIASdjProtocol(8000, 80, [10], 1000, 1000, 0, 100, 60, ‘soa’, 0, 15e3, .33, 1, 20)

MaketoneGPIASdjProtocol(8000, 80, [0 1 2 4 8 16 32 64 128 256], 1000, 1000, 0, 100, 50, ‘isi’, 0, 2e3, 0, 1, 15)

carrier_freq=8000; carrier_amp=80; gapdurs=[0 32 256 ]; gapdelay=1000; poststartle=1000; pulsedur=25; pulseamps=110; soa=50; soaflag=’isi’; ramp=3; isi=5000; isi_var=0; IL=0; nreps=20; MakeToneGPIASdjProtocol(carrier_freq, carrier_amp, gapdurs, gapdelay, poststartle, pulsedur, pulseamps, soa, soaflag, ramp, isi, isi_var, IL, nreps)

djtools.MakeTonedjProtocol(freqsperoctave, minfreq, maxfreq, numamplitudes, minamplitude, maxamplitude, durations, ramp, include_whitenoise, interleave_laser, include_silent_sound, isi, nrepeats)#
Usage: [filename,path]=MakeTonedjProtocol(freqsperoctave, …

minfreq, maxfreq, numamplitudes, … minamplitude, maxamplitude, durations, ramp, include_whitenoise,… interleave_laser, include_silent_sound, isi, nrepeats)

same as MakeTuningCurveOct from exper, except that you can tell it interleave laser trials

INPUTS: freqsperoctave: number of frequencies per octave (frequency resolution) minfreq: lowest frequency in Hz maxfreq: highest frequency in Hz

note: if minfreq-to-maxfreq cannot be divided evenly into freqsperoctave, the nearest maxfreq will be used (i.e. the requested freqsperoctave will be exactly enforced)

numamplitudes: number of amplitude steps minamplitude: maximum amplitude in dB SPL (requires system to be calibrated) maxamplitude: maximum amplitude in dB SPL (requires system to be calibrated) durations: vector of different tone durations (in ms) (can be a single duration) ramp: on-off ramp duration in ms include_whitenoise: 0 or 1 to include white noise bursts at each amplitude interleave_laser: 0 or 1 to duplicate all stimuli and interleave laser

and non-laser trials in random order

include_silent_sound: 0 or 1 to include an extra stimulus that is silent,

useful for explicitly collecting spontaneous and/or laser-only trials as a separate condition

isi: inter stimulus interval (onset-to-onset) in ms nrepeats: number of repetitions (different pseudorandom orders) OUTPUTS:

  • creates a suitably named stimulus protocol in djprefs.stimuliTone Protocols

  • returns name & path to protocol (AKH 6/19/13)

example call: MakeTonedjProtocol(4, 4000, 64000, 4, 20, 80, 25, 3, 1, 1, 1, 500, 10)

example call with multiple durations: MakeTonedjProtocol(4, 1000, 32000, 3, 50, 80, [200 400],10,1,1, 1, 500, 10) MakeTonedjProtocol(4, 4000, 64000, 3, 50, 80, 25,3,1,0, 1, 500, 10)

For white noise only of several durations: MakeTonedjProtocol(0, 0, 0, 4, 20, 80, [1 2 4 8 16 32 64 128 256],0,1,1, 1, 1000, 10)

freqsperoctave= 6; minfreq= 4e3; maxfreq= 64e3; numamplitudes= 1; minamplitude= 70; maxamplitude= 70; durations= 400; ramp=3; include_whitenoise= 1; interleave_laser= 0; include_silent_sound= 0; isi= 500; nrepeats= 20; MakeTonedjProtocol(freqsperoctave, minfreq, maxfreq, numamplitudes, minamplitude, maxamplitude, durations, ramp, include_whitenoise, interleave_laser, include_silent_sound, isi, nrepeats)

to include only whitenoise, use freqsperoctave==0 & minfreq==0 & maxfreq==0 & include_whitenoise==1

djtools.MakeVarGPIASdjProtocol(noiseamp, gapdurs, gapdelay, post_startle_duration, pulsedur, pulseamps, soa, soaflag, ramp, isi, isi_var, nrepeats)#
usage MakeVarGPIASdjProtocol(noiseamp, gapdurs, gapdelay, post_startle_duration,

pulsedur, pulseamps, soa, soaflag, ramp, iti, iti_var, interleave_laser, nrepeats)

creates a djmaus stimulus protocol file for GPIAS (gap-induced pre-pulse inhibition of acoustic startle response). can use multiple gap durations, gap is silent using variable ITI.

this version randomly interleaves trial with a laser pulse for each GPIAS trial,

the laser is on exactly during the gap. I.e. laser onset coincides with gap onset, laser duration matches gap duration

djtools.NextDataDir()#

simple utility to cd to the alphanumerically next data directory I wrote this because I was tired of scrolling through a long list of data directories every time you cd ..

djtools.Outfile_Combiner(varargin)#

simple GUI to pick multiple outfiles and combine them. developed for ABRs (LFP tuning curves) so that we can split data acquisition across multiple sessions

Usage: click “Browse and Add” to select outfiles and add them to the list of outfiles that you want to combine. Once you’re finished adding files to the list, then click “Combine them” which will generate an “out_combined.mat” file in the chronologically first directory. To plot the combined file, run PlotTC_LFP without any input and use the dialog box to select the combined outfile.

current version only allows outfiles with identical frequencies/amplitudes, but in the future we can revise it to combine outfiles with different parameters.

You can also run without the GUI by passing a filelist. This should be a cell array of absolute filenames (including path) passed as the first argument. In this case, you can (optionally) include the destination directory for the combined outfile as the second argument (defaults to current directory)

djtools.Plot2ToneCellMovements(varargin)#

currently just works with stimuli for Yashar, WN and laser pulses

djtools.Plot2ToneTC_PSTH_old(expdate1, session1, filenum1, varargin)#

modified for plotting stimuli for Yashar, Process2Tone_single2 extracts spikes and plots a single psth tuning curve usage: Plot2toneTC_psth(expdate, session, filenum, thresh, xlimits, ylimits) (thresh, xlimits, and ylimits are optional)

thresh is in number of standard deviations

E2 analysis function mw 070406

djtools.Plot2Tone_LFP_single2(varargin)#

plots a single file of clustered spiking 2 tone data from djmaus

usage: Plot2Tone_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.Plot2Tone_PSTH(varargin)#

plots clustered spiking 2 tone data from djmaus

usage: Plot2Tone_PSTH([datadir], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-.5*dur 1.5*dur] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.Plot2Tone_PSTH2(varargin)#

plots clustered spiking 2 tone data from djmaus

usage: Plot2Tone_PSTH([datadir], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-.5*dur 1.5*dur] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.Plot2Tone_PSTH_single(varargin)#

plots a single file of clustered spiking 2 tone data from djmaus

usage: Plot2Tone_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.Plot2Tone_PSTH_single2(varargin)#

plots a single file of clustered spiking 2 tone data from djmaus

usage: Plot2Tone_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.Plot2Tone_PSTH_single_public(datadir, clust)#

example: Plot2Tone_PSTH_single_public(pwd, 21) to plot cell 21 (outfile name) from the outfile located in working directory

djtools.PlotAsymGPIAS_PSTH(varargin)#

plots clustered spiking AsymGPIAS data from djmaus

usage: PlotAsymGPIAS_PSTH([datapath], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) (all inputs are optional)

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-1.5*max(gapdurs) 2*soa]; ylimits defaults to an autoscaled value

tetrode number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotAsymGPIAS_PSTH_single(varargin)#

plots a single file of clustered spiking AsymGPIAS data from djmaus

usage: PlotAsymGPIAS_PSTH(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotClicktrain_PSTH(varargin)#

plots clustered spiking Clicktrain data from djmaus

usage: PlotClicktrain_PSTH([datapath], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) (all inputs are optional)

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-1.5*max(gapdurs) 2*soa]; ylimits defaults to an autoscaled value

tetrode number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotClicktrain_PSTH_single(varargin)#

plots a single file of clustered spiking Clicktrain data from djmaus

usage: PlotClicktrain_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotFlashtrain_PSTH(varargin)#

plots clustered spiking Clicktrain data from djmaus

usage: PlotFlashtrain_PSTH([datapath], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) (all inputs are optional)

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-1.5*max(gapdurs) 2*soa]; ylimits defaults to an autoscaled value

tetrode number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotFlashtrain_PSTH_single(varargin)#

plots a single file of clustered spiking Flashtrain data from djmaus

usage: PlotFlashtrain_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotGPIAS_Behavior(datadir)#

plots GPIAS behavioral data from djmaus and open-ephys accelerometers

usage: PlotGPIAS_Behavior(datadir) Processes data if outfile is not found;

djtools.PlotGPIAS_Behavior_HeadFixed(varargin)#
djtools.PlotGPIAS_Behavior_kip(datadir)#

plots GPIAS behavioral data from djmaus and open-ephys accelerometers

usage: PlotGPIAS_Behavior(datadir) Processes data if outfile is not found;

adds on GTR and burst data from all cells with outfiles in pwd _kip version adds on GTR and burst data from all cells with outfiles in pwd should be cleaned up

djtools.PlotGPIAS_Behavior_varlaser(datadir)#

plots GPIAS behavioral data from djmaus and open-ephys accelerometers

usage: PlotGPIAS_Behavior_varlaser(datadir)

modified from PlotGPIAS_Behavior_kip mw 10.29.2018 this version is for behavioral data with variable laser pulse trains or pulse timing

Processes data if outfile is not found;

adds on GTR and burst data from all cells with outfiles in pwd _kip version adds on GTR and burst data from all cells with outfiles in pwd should be cleaned up

djtools.PlotGPIAS_PSTH(varargin)#

plots clustered spiking GPIAS data from djmaus

usage: PlotGPIAS_PSTH([datapath], [tetrode], [clust], [xlimits],[ylimits], [binwidth], [‘force-reprocess’]) (all inputs are optional)

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-1.5*max(gapdurs) 2*soa]; ylimits defaults to an autoscaled value ‘force-reprocess’ can be in any position

tetrode number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotGPIAS_PSTH_single(varargin)#

plots a single file of clustered spiking GPIAS data from djmaus

usage: PlotGPIAS_PSTH(datapath, t_filename, [xlimits],[ylimits], [binwidth], [‘force-reprocess’]) (xlimits, ylimits, binwidth, ‘force-reprocess’ are optional)

Processes data if outfile is not found;

djtools.PlotGPIASflashtrain_PSTH(varargin)#

plots clustered spiking GPIAS data from djmaus

usage: PlotGPIASflashtrain_PSTH([datapath], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) (all inputs are optional)

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-1.5*max(gapdurs) 2*soa]; ylimits defaults to an autoscaled value

tetrode number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotGPIASflashtrain_PSTH_single(varargin)#

plots a single file of clustered spiking GPIAS flashtrain data from djmaus this has a train of laser pulses with varying pulewidth

usage: PlotflashtrainGPIAS_PSTH(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotGTR_Duration_Curves(varargin)#

UNTITLED SummaryTuning of this function goes here Detailed explanation goes here

djtools.PlotLFPs_depth(varargin)#

plots LFPs from tone or WN stimulus according to depth

djtools.PlotPDR(varargin)#

Plots PDR alone or with data if given (datadir, video_file, xlimtis, ylimits) ira 08.31.17

djtools.PlotPINPWN_PSTH_single(varargin)#

plots a single file of clustered spiking tuning curve data from djmaus this function plots silent sounds with laser on, that’s it.

usage: PlotPINP_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotPINP_PSTH(varargin)#

plots clustered spiking PINP data from djmaus

usage: PlotPINP_PSTH([datadir], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [0 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotPINP_PSTH_single(varargin)#

plots a single file of clustered spiking tuning curve data from djmaus this function plots silent sounds with laser on, that’s it.

usage: PlotPINP_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotPPI_Behavior(datadir)#

plots PPI behavioral data from djmaus using the tilt platform (pressure transducer)

usage: PlotPPI_Behavior(datadir) Processes data if outfile is not found;

adds on GTR and burst data from all cells with outfiles in pwd

djtools.PlotSoundfile(varargin)#

plots clustered spiking tuning curve data from djmaus

usage: PlotSoundfile([datadir], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-100 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotSoundfile_single(varargin)#

plots a single file of clustered spiking tuning curve data from djmaus

usage: PlotTC_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotSustainedSuppression(varargin)#

plots clustered spiking PINP data from djmaus

usage: PlotSustainedSuppression([datadir], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [0 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotSustainedSuppression_single(varargin)#

plots a single file of clustered spiking tuning curve data from djmaus this function plots silent sounds with laser on, that’s it.

usage: PlotSustainedSuppression_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PlotTC_LFP(varargin)#

plots continuous tuning curve data from djmaus

usage: PlotTC_LFP(datapath, [channel], [xlimits],[ylimits]) (xlimits & ylimits are optional) xlimits default to [0 200] channel number should be an integer

Processes data if outfile is not found;

djtools.PlotTC_PSTH(varargin)#

plots clustered spiking tuning curve data from djmaus

usage: PlotTC_PSTH([datadir], [tetrode], [clust], [xlimits],[ylimits], [binwidth]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-100 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer clust can be an integer or an array of integers

Processes data if outfile is not found;

djtools.PlotTC_PSTH_single(varargin)#

plots a single file of clustered spiking tuning curve data from djmaus

usage: PlotTC_PSTH_single(datapath, t_filename, [xlimits],[ylimits], [binwidth]) (xlimits, ylimits, binwidth are optional)

Processes data if outfile is not found;

djtools.PreviousDataDir()#

simple utility to cd to the alphanumerically previous data directory I wrote this because I was tired of scrolling through a long list of data directories every time you cd ..

djtools.Process2Tone_LFP_single2(varargin)#

tailored to plot Yashar’s stimuli, comparing tones vs laser pulses processes a single .t file of clustered spiking 2 tone curve data from djmaus

usage: Process2tone_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-.5*dur SOA+1.5*dur] channel (tetrode) number should be an integer, if omitted you will be prompted for it automatically processes dafunction ProcessTC_PSTH_single(varargin)

djtools.Process2Tone_PSTH(varargin)#

Processes clustered spiking 2 tone data from djmaus

usage: ProcessTC_PSTH([datadir], [tetrode], [cluster], [xlimits], [ylimits]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-100 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer saves to outfile

djtools.Process2Tone_PSTH2(varargin)#

Processes clustered spiking 2 tone data from djmaus

usage: ProcessTC_PSTH([datadir], [tetrode], [cluster], [xlimits], [ylimits]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-100 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer saves to outfile

djtools.Process2Tone_PSTH_single(varargin)#

processes a single .t file of clustered spiking 2 tone curve data from djmaus

usage: Process2tone_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-.5*dur SOA+1.5*dur] channel (tetrode) number should be an integer, if omitted you will be prompted for it automatically processes dafunction ProcessTC_PSTH_single(varargin)

djtools.Process2Tone_PSTH_single2(varargin)#

tailored to plot Yashar’s stimuli, comparing tones vs laser pulses processes a single .t file of clustered spiking 2 tone curve data from djmaus

usage: Process2tone_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-.5*dur SOA+1.5*dur] channel (tetrode) number should be an integer, if omitted you will be prompted for it automatically processes dafunction ProcessTC_PSTH_single(varargin)

djtools.Process2Tone_PSTH_single2(2)

tailored to plot Yashar’s stimuli, comparing tones vs laser pulses processes a single .t file of clustered spiking 2 tone curve data from djmaus

usage: Process2tone_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-.5*dur SOA+1.5*dur] channel (tetrode) number should be an integer, if omitted you will be prompted for it automatically processes dafunction ProcessTC_PSTH_single(varargin)

djtools.ProcessAsymGPIAS_PSTH(varargin)#

Processes clustered spiking AsymGPIAS data from djmaus

usage: ProcessAsymGPIAS_PSTH([datadir], [tetrode], [cluster], [xlimits], [ylimits]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [0 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer saves to outfile

djtools.ProcessAsymGPIAS_PSTH_single(varargin)#

processes a single .t file of clustered spiking AsymGPIAS data from djmaus

usage: ProcessAsymGPIAS_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-1.5*max(gapdurs) 2*soa] saves to outfile

djtools.ProcessClicktrain_PSTH(varargin)#

processes clustered spiking Clicktrain data from djmaus

usage: ProcessClicktrain_PSTH([datadir], [tetrode], [cluster], [xlimits], [ylimits]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [0 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer saves to outfile

djtools.ProcessClicktrain_PSTH_single(varargin)#

processes a single .t file of clustered spiking Clicktrain data from djmaus

usage: ProcessClicktrain_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-1.5*max(gapdurs) 2*soa] saves to outfile

djtools.ProcessFlashtrain_PSTH_single(varargin)#

processes a single .t file of clustered spiking Flashtrain data from djmaus

usage: ProcessFlashtrain_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-1.5*max(gapdurs) 2*soa] saves to outfile

djtools.ProcessGPIAS_Behavior(datadir)#

processes accelerometer behavioral data from djmaus

usage: ProcessGPIAS_Behavior(datadir) saves to outfile

djtools.ProcessGPIAS_BehaviorMouse2(out)#
modified from ProcessGPIAS_BehaviorTilt,

this is called from ProcessGPIAS_BehaviorTilt to plot behavior from a second simultaneously recorded mouse

processes behavioral data from djmaus

usage: ProcessGPIAS_BehaviorMouse2(out) but not meant to be called directly saves to outfile

djtools.ProcessGPIAS_BehaviorTilt(datadir, flag_accel)#

processes accelerometer behavioral data from djmaus

usage: ProcessGPIAS_Behavior(datadir,flag_accel)) saves to outfile

djtools.ProcessGPIAS_BehaviorTiltvarlaser(datadir, flag_accel)#

processes piezo (tilt platform) and accelerometer behavioral data from djmaus

usage: ProcessGPIAS_BehaviorTiltvarlaser(datadir,flag_accel)) saves to outfile

djtools.ProcessGPIAS_Behavior_HeadFixed(datadir)#

processes accelerometer behavioral data from djmaus

usage: ProcessGPIAS_Behavior(datadir) saves to outfile

djtools.ProcessGPIAS_Behavior_old(datadir)#

processes accelerometer behavioral data from djmaus

usage: ProcessGPIAS_Behavior(datadir) saves to outfile

djtools.ProcessGPIAS_PSTH(varargin)#

processes clustered spiking GPIAS data from djmaus

usage: ProcessGPIAS_PSTH([datadir], [tetrode], [cluster], [xlimits], [ylimits]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [0 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer saves to outfile

djtools.ProcessGPIAS_PSTH_single(varargin)#

processes a single .t file of clustered spiking GPIAS data from djmaus

usage: ProcessGPIAS_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-1.5*max(gapdurs) 2*soa] saves to outfile

djtools.ProcessGPIASflashtrain_PSTH_single(varargin)#

processes a single .t file of clustered spiking GPIAS data from djmaus

usage: ProcessGPIAS_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [-1.5*max(gapdurs) 2*soa] saves to outfile

djtools.ProcessPINP_LFP(varargin)#
djtools.ProcessPINP_PSTH_single(varargin)#

processes a single .t file of clustered spiking PINP data from djmaus

usage: ProcessPINP_PSTH_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional)

customized to process a PINP protocol. It will only look for (1) silent sound, (2) silent sound with a single laser pulse, and (3) silent sound with laser flash trains

djtools.ProcessPPI_BehaviorTilt(datadir, flag_accel)#

processes PPI behavioral data from djmaus using the tilt platform (pressure sensor)

usage: ProcessPPI_Behavior(datadir,flag_accel)) saves to outfile

djtools.ProcessSoundfile_single(varargin)#

processes a single .t file of clustered spiking tuning curve data from djmaus

usage: ProcessSoundfile_single(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [0 200] channel (tetrode) number should be an integer, if omitted you will be prompted for it automatically processes dafunction ProcessTC_PSTH_single(varargin)

djtools.ProcessTC_LFP(varargin)#

processes continuous tuning curve data from djmaus. sorts Open Ephys continuous data into a big response matrix. use for LFP, WC, or other continuous data (i.e. does not extract spikes)

usage: ProcessTC_OE(datapath, [channel], [xlimits], [ylimits]) channel is a number not a string saves output in an outfile

notes: whitenoise plotted as freq=-1 kHz, silent sound as -2 kHz

data are in microvolts

djtools.ProcessTC_PSTH(varargin)#

Processes clustered spiking tuning curve data from djmaus

usage: ProcessTC_PSTH([datadir], [tetrode], [cluster], [xlimits], [ylimits]) Everything is optional. if omitted, the following defaults are used:

datadir defaults to the current directory tetrode defaults to all tetrodes in data directory cluster defaults to all clusters xlimits defaults to [-100 200] ylimits defaults to an autoscaled value

channel (tetrode) number should be an integer saves to outfile

djtools.ProcessTC_PSTH_single(varargin)#

processes a single .t file of clustered spiking tuning curve data from djmaus

usage: ProcessTC_PSTH(datadir, t_filename, [xlimits],[ylimits]) (xlimits, ylimits are optional) xlimits default to [0 200] channel (tetrode) number should be an integer, if omitted you will be prompted for it automatically processes dafunction ProcessTC_PSTH_single(varargin)

djtools.ProcessTC_PupilMotion(varargin)#
processes continous traces from pupil and ball motion, similarly to LFP

trace.

make sure to analyze pupil first EyeVidDLC_Points -> post_DeepLab_pupil_correction to save pupil_long_axis.mat getBallMotion(datadir) to save moves_trace1.mat

djtools.Pupil_Dilation(dir, video_file)#

loads mp4 file requires user input to find pupil ira 8.31.17

djtools.ReKilosort#

Resort Tool - SFM 8/11/21

djtools.ReadHeader(fp)#

H = ReadHeader(fp)

Reads NSMA header, leaves file-read-location at end of header

INPUT:

djtools.ResolveEventMismatch(Events, all_SCTs, stimlog)#

try to resolve the situation when the number of sound events (from network messages) does not match Number of hardware triggers (soundcardtrig TTLs

djtools.SCT_Monitor(datadir, StartAcquisitionSec, Events, all_channels_data, all_channels_timestamps, all_channels_info)#

plots soundcard triggers, timestamps, and network messages as a sanity check and way to monitor the data processing for a given data file this used to be a commented-out stanza in each processing function but I’m pulling it out for modularity mw 1-30-2017

djtools.SpiketrainCorrelation#

simple script that compares an MClust outfile to a Kilosort outfile you select the outfiles with a dialog box plots a cross-correlation and prints out the correlation coefficient

djtools.SpiketrainCorrelationAll()#

simple script that compares the MClust outfiles to the Kilosort outfiles in the current directory (all possible combinations, so it takes a while to run) plots a correlation matrix of r values and the cross-correlations

djtools.SpiketrainCorrelationtemp#

plots a cross-correlation and prints out the correlation coefficient

class djtools.VideoReaderFFMPEG(vFileName, varargin)#

For reading videos - needed it since the builtin VIDEOREADER wouldn’t accept h264 encoded files - this is a simple command line wrapper for FFMPEG. Exposes a simple interface that implements a subset of the builtin

CONSTRUCTOR:

vr = VideoReaderFFMPEG(fileName, ‘tempFolder’, tempFolder, ‘FFMPEGPath’, FFMPEGPath, ‘imageFormat’, imageFormat, ‘verbose’, verbose);

PARAMS:

fileName - path to video file tempFolder - OPTIONAL - location to store temporary files, defaults to ‘./’ FFMPEGPath - OPTIONAL - location of FFMPEG/FFPROBE executables,

defaults to ‘/usr/local/bin’ (OSX/UNIX) or ‘C:Program Filesffmpegbin’ (WIN)

imageFormat - OPTIONAL - format used as a temporary frame store, defaults to ‘tif’ verbose - OPTIONAL - display ffmpeg output messages, defaults to false (not output)

METHODS:
read(frames) - single frames or a range of frames [startFrame endFrame],

returns frames as a [WIDTH x HEIGHT x CHANNELS x NFRAMES] matrix

clean() - delete all temporary files

PROPERTIES:

Width, Height, NumberOfFrames, FrameRate, Channels tempName, tempFolder, imageFormat buffered, bufferSize, bufferedFrameTimes,

see also VIDEOREADER

NumberOfFrames = None#

buffer params:

VideoReaderFFMPEG(vFileName, varargin)#

parse input arguments

buffered = None#

name for temporary tiff files - to avoid buffer collision if multiple instances of VideoReaderFFMPEG access the same tempFolder

clean()#

delete temporary images from disk

delete()#

delete temporary images from disk when deleting the object

read(frameNumber)#

frame = read(frameNumber); frames = read([startFrameNumner endFrameNumber]); returns frames as a [WIDTH x HEIGHT x CHANNELS x NFRAMES] matrix direct or buffered (experimental, set obj.buffered=true) reading of frames

vFileName = None#

input parameters:

vr = None#

unused - delete or keep for compatibility?

djtools.age(dob, day)#

returns age of animal in days usage:

age(dob) to get animal’s age today age(dob, date) to get animal’s age on a particular date

djtools.analTemp3(varargin)#

usage: analTemp3(datapath, t_filename, [xlimits],[ylimits], [binwidth], Type) (xlimits, ylimits, binwidth are optional), argin Type is useful as: ‘WN w/o laser’, ‘GPIAS w/o burst’, ‘GPIAS w/ burst’

reprocesses data if outfile is not found or xlimits are wrong; analTemp1 is outdated (3/23/17) differs from analTemp2 by using global CELL_STATS instead of PV_STATS

djtools.circfit(x, y)#

[xc yx R] = circfit(x,y)

fits a circle in x,y plane in a more accurate (less prone to ill condition )

procedure than circfit2 but using more memory x,y are column vector where (x(i),y(i)) is a measured point

result is center point (yc,xc) and radius R an optional output is the vector of coeficient a

describing the circle’s equation

x^2+y^2+a(1)*x+a(2)*y+a(3)=0

By: Izhak bucher 25/oct /1991,

djtools.circle(center, radius, NOP, style)#

H=CIRCLE(CENTER,RADIUS,NOP,STYLE) This routine draws a circle with center defined as a vector CENTER, radius as a scaler RADIS. NOP is the number of points on the circle. As to STYLE, use it the same way as you use the rountine PLOT. Since the handle of the object is returned, you use routine SET to get the best result.

Usage Examples,

circle([1,3],3,1000,’:’); circle([2,4],2,1000,’–‘);

Zhenhai Wang <zhenhai@ieee.org> Version 1.00 December, 2002

djtools.clean_kilosort()#

this is a simple utility that deletes all kilosort output from a data directory. It runs on the current working directory (pwd). This allows you to start from scratch and re-kilosort the directory. If there is a dirs.mat, it will also delete all kilosort output from the other directories listed in dirs.mat. With some “are you sure” windows.

djtools.computeAllMeasuresKS(resultsDirectory)#

taken from https://github.com/cortex-lab/sortingQuality

djtools.dBPSD(Px, sensitivity)#

usage: dBPSD=dBPSD(Px, sensitivity) inputs:

Px: power spectral density of the voltage measured from the output of the B&K microphone

this is one element of the Pxx array returned by pwelch

sensitivity: sensitivity setting on the B&K amplifier, in volts

(e.g. .1, .316, 1 V/Pa)

output: the power of the sound in dB SPL (re: 20 microPa)

algorithm: worked backwards from measurement using the B&K calibrator at .316 v/Pa: 94 dB produces a Pxx of .0076 (.31 Vrms, 1 Vp-p) 114 dB produces a Pxx of .7620 (3.1 Vrms, 9Vp-p)

at 1 v/Pa: 94 dB produces a Pxx of .0757 (1 Vrms, 3 Vp-p) 114 dB produces a Pxx of 5.6720 (9.75 Vrms, 27 Vp-p)

at 3.16 v/Pa: 94 dB produces a Pxx of .7620 (3.10 Vrms 114 dB produces a Pxx of 6.96 (clips on scope)

djtools.dBSPL(Vrms, sensitivity)#

usage: dBSPL=dBSPL(Vrms, sensitivity) inputs:

Vrms: cycle RMS voltage measured from the output of the B&K microphone sensitivity: sensitivity setting on the B&K amplifier, in volts

(e.g. .1, .316, 1 V/Pa)

Vrms = (peak to peak)/sqrt(2)

output: the power of the sound in dB SPL (re: 20 microPa)

djtools.djtools#

go to the djtools folder

djtools.djxml2struct(file)#

Convert xml file into a MATLAB structure [ s ] = xml2struct( file )

A file containing: <XMLname attrib1=”Some value”>

<Element>Some text</Element> <DifferentElement attrib2=”2”>Some more text</Element> <DifferentElement attrib3=”2” attrib4=”1”>Even more text</DifferentElement>

</XMLname>

Will produce: s.XMLname.Attributes.attrib1 = “Some value”; s.XMLname.Element.Text = “Some text”; s.XMLname.DifferentElement{1}.Attributes.attrib2 = “2”; s.XMLname.DifferentElement{1}.Text = “Some more text”; s.XMLname.DifferentElement{2}.Attributes.attrib3 = “2”; s.XMLname.DifferentElement{2}.Attributes.attrib4 = “1”; s.XMLname.DifferentElement{2}.Text = “Even more text”;

Please note that the following characters are substituted ‘-’ by ‘_dash_’, ‘:’ by ‘_colon_’ and ‘.’ by ‘_dot_’

Written by W. Falkena, ASTI, TUDelft, 21-08-2010 Attribute parsing speed increased by 40% by A. Wanner, 14-6-2011 Added CDATA support by I. Smirnov, 20-3-2012

Modified by X. Mo, University of Wisconsin, 12-5-2012

djtools.eyetracking#

E:djmaus-datairaira2017-11-26_16-15-50_mouse-7827

djtools.fit_ellipse(x, y, axis_handle)#

fit_ellipse - finds the best fit to an ellipse for the given set of points.

Format: ellipse_t = fit_ellipse( x,y,axis_handle )

Input: x,y - a set of points in 2 column vectors. AT LEAST 5 points are needed !
axis_handle - optional. a handle to an axis, at which the estimated ellipse

will be drawn along with it’s axes

Output: ellipse_t - structure that defines the best fit to an ellipse

a - sub axis (radius) of the X axis of the non-tilt ellipse b - sub axis (radius) of the Y axis of the non-tilt ellipse phi - orientation in radians of the ellipse (tilt) X0 - center at the X axis of the non-tilt ellipse Y0 - center at the Y axis of the non-tilt ellipse X0_in - center at the X axis of the tilted ellipse Y0_in - center at the Y axis of the tilted ellipse long_axis - size of the long axis of the ellipse short_axis - size of the short axis of the ellipse status - status of detection of an ellipse

Note: if an ellipse was not detected (but a parabola or hyperbola), then

an empty structure is returned

djtools.getBallMotion(varargin)#

Read events from raspberry Pi and decode running speed.

djtools.getContinuousFilename(datadir, channel)#

figures out the filename for the continuous channel

djtools.getDepth16(varargin)#

Figure ouc che depch of cells in recordings wich silicon probes dir, ch, c, depch (micromanipulacor)

djtools.getDepth32(varargin)#

Figure ouc the depth of cells in recordings wich silicon probes dir, ch, c, depch (micromanipulacor)

djtools.getKScellQuals(cellnum)#
djtools.getLaserfile(datadir)#

reads settings.xml in datadir to figure out which node the Laser was recorded on, and hence what the filename is usage: [ fname ] = getLaserfile( datadir )

djtools.getNodes(datadir)#

reads settings.xml in datadir to figure out which nodes are being used

djtools.getSCTfile(datadir)#

reads settings.xml in datadir to figure out which node the soundcardtrig was recorded on, and hence what the filename is usage [ fname ] = getSCTfile( datadir )

djtools.getStimfile(datadir)#

reads settings.xml in datadir to figure out which node the stim (sound monitor) was recorded on, and hence what the filename is usage [ fname ] = getStimfile( datadir )

djtools.get_session_info(directory)#

STEP 1: GET FULL PATH FOR DIRECTORY

djtools.getfilesize(fid)#
djtools.inversedBSPL(dBSPL, sensitivity)#

what Vrms do you need on the B&K mic to achieve a desired dBSPL? usage: Vrms=inversedBSPL(dBSPL, sensitivity) inputs:

dBSPL: the desired power of the sound in dB SPL (re: 20 microPa) sensitivity: sensitivity setting on the B&K amplifier, in volts

(e.g. .1, .316, 1 V/Pa)

output: Vrms: cycle RMS voltage you need to measure from the output of the B&Kmicrophone that corresponds to your desired dBSPL

djtools.load_open_ephys_data(filename)#

[data, timestamps, info] = load_open_ephys_data(filename)

Loads continuous, event, or spike data files into Matlab.

Inputs:

filename: path to file

Outputs:

data: either an array continuous samples (in microvolts),

a matrix of spike waveforms (in microvolts), or an array of event channels (integers)

timestamps: in seconds

info: structure with header and other information

DISCLAIMER:

Both the Open Ephys data format and this m-file are works in progress. There’s no guarantee that they will preserve the integrity of your data. They will both be updated rather frequently, so try to use the most recent version of this file, if possible.

djtools.load_open_ephys_data1(filename)#

[data, timestamps, info] = load_open_ephys_data(filename)

Loads continuous, event, or spike data files into Matlab.

Inputs:

filename: path to file

Outputs:

data: either an array continuous samples, a matrix of spike waveforms,

or an array of event channels

timestamps: in seconds

info: structure with header and other information

DISCLAIMER:

Both the Open Ephys data format and this m-file are works in progress. There’s no guarantee that they will preserve the integrity of your data. They will both be updated rather frequently, so try to use the most recent version of this file, if possible.

djtools.load_open_ephys_data_faster(filename, varargin)#

[data, timestamps, info] = load_open_ephys_data(filename, [outputFormat])

Loads continuous, event, or spike data files into Matlab.

Inputs:

filename: path to file outputFormat: (optional) If omitted, continuous data is output in double format and is scaled to reflect microvolts.

If this argument is ‘unscaledInt16’ and the file contains continuous data, the output data will be in int16 format and will not be scaled; this data must be manually converted to a floating-point format and multiplied by info.header.bitVolts to obtain microvolt values. This feature is intended to save memory for operations involving large amounts of data.

Outputs:

data: either an array continuous samples (in microvolts unless outputFormat is specified, see above),

a matrix of spike waveforms (in microvolts), or an array of event channels (integers)

timestamps: in seconds

info: structure with header and other information

DISCLAIMER:

Both the Open Ephys data format and this m-file are works in progress. There’s no guarantee that they will preserve the integrity of your data. They will both be updated rather frequently, so try to use the most recent version of this file, if possible.

djtools.load_open_ephys_network_events(filename)#

modified from load_open_ephys_data to work with network events messages, which were not handled by the original load_open_ephys_data mw 8.23.2016

djtools.mackskill(M, treatments, blocks)#

load popcorn M = popcorn; reps = 3;

djtools.maskedClusterQualityKS(resultsDirectory)#
djtools.nanfastsmooth(Y, w, type, tol)#

nanfastsmooth(Y,w,type,tol) smooths vector Y with moving average of width w ignoring NaNs in data..

Y is input signal. w is the window width.

The argument “type” determines the smooth type:

If type=1, rectangular (sliding-average or boxcar) If type=2, triangular (2 passes of sliding-average) If type=3, pseudo-Gaussian (3 passes of sliding-average)

The argument “tol” controls the amount of tolerance to NaNs allowed between 0 and 1. A value of zero means that if the window has any NaNs in it then the output is set as NaN. A value of 1 allows any number of NaNs in the window and will still give an answer for the smoothed signal. A value of 0.5 means that there must be at least half real values in the window for the output to be valid.

The start and end of the file are treated as if there are NaNs beyond the dataset. As such the behaviour depends on the value of ‘tol’ as above. With ‘tol’ set at 0.5 the smoothed signal will start and end at the same time as the orgional signal. However it’s accuracy will be reduced and the moving average will become more and more one-sided as the beginning and end is approached.

fastsmooth(Y,w,type) smooths with tol = 0.5. fastsmooth(Y,w) smooths with type = 1 and tol = 0.5

Version 1.0, 26th August 2015. G.M.Pittam
  • First Version

Version 1.1, 5th October 2015. G.M.Pittam
  • Updated to correctly smooth both even and uneven window length.

  • Issue identified by Erik Benkler 5th September 2015.

Modified from fastsmooth by T. C. O’Haver, May, 2008.

djtools.nansem(x, dim)#

FORMAT: Y = NANSEM(X,DIM)

Standard error of the mean ignoring NaNs

NANSTD(X,DIM) calculates the standard error of the mean along any dimension of the N-D array X ignoring NaNs.

If DIM is omitted NANSTD calculates the standard deviation along first non-singleton dimension of X.

Similar functions exist: NANMEAN, NANSTD, NANMEDIAN, NANMIN, NANMAX, and NANSUM which are all part of the NaN-suite.

djtools.oldMakeGapShockdjProtocol()#

usage: oldMakeGapShockdjProtocol this was the original way we made a Gap Shock Protocol, by hijacking the laser pulse and using it to trigger the S88. But now we want to use both lasers and shock together and independently. So this function is obsolete

djtools.probe_64_config#

layout1(i)= layout2(i)=

djtools.process_GPtcCellList#

process_GPtcCellList - based on process_all_cells_kip3, which is loosely based on process_all_cells by MIke processes and plots some summary stats for GPtc tests from a GPtc-only cell list calls analTemp3 to actually do the analyses

djtools.process_all_behavior#

this is an example script that you can use as a template to process all cells in a cell list that you have built using CellListBuilder. mike 12-2016

djtools.process_all_cells_GIN#

this is an example script that you can use as a template to process all cells in a cell list that you have built using CellListBuilder. mike 12-2016

djtools.process_all_cells_TEST#

this is an example script that you can use as a template to process all cells in a cell list that you have built using CellListBuilder. mike 12-2016

djtools.process_all_cells_example#

this is an example script that you can use as a template to process all cells in a cell list that you have built using CellListBuilder. mike 12-2016

djtools.process_all_cells_kip3#

process_all_cells_kip3 this is an example script that you can use as a template to process all cells in a cell list that you have built using CellListBuilder. mike 12-2016

kip3 opens and displays data from cell_list1 and cell_list2

djtools.process_all_cells_nickCT#

this is an example script that you can use as a template to process all cells in a cell list that you have built using CellListBuilder. mike 12-2016

djtools.process_all_cells_nickFT#

this is an example script that you can use as a template to process all cells in a cell list that you have built using CellListBuilder. mike 12-2016

djtools.rdir(rootdir, varargin)#

RDIR - Recursive directory listing

D = rdir(ROOT) D = rdir(ROOT, TEST) D = rdir(ROOT, TEST, RMPATH) D = rdir(ROOT, TEST, 1) D = rdir(ROOT, ‘’, …) [D, P] = rdir(…) rdir(…)

Inputs

  • ROOT

rdir(ROOT) lists the specified files. ROOT can be a pathname, filename, or can include both. One can use absolute and relative pathnames and wildcards (*). Wildcard can be placed anywhere and used many times like ‘path**.m’

One can also use a double wildcard (**) to match multiple directory levels. For example ROOT = ‘path***.m’ will match all “.m” files in “path” and all subdirectories of “path”.

NOTE : “.svn” directories created by SubVersion (SVN) are excluded from the recursive listing.

  • TEST

Optional test that can be performed on the returned files.

TEST is a string indicating expression to be evaluated on selected field of rdir output. All fields (ie name, date, bytes, isdir and datenum) can be used.

Tests are strings similar to what one would use in a “if” statement e.g.

‘bytes>1024 & datenum>now-7’

One can also use function like “regexp” or “strfind” with string fields like “name” and “date” e.g ‘regexp(name, ‘expr’)’. In that case, tests that return a non empty value are considered as true.

regexp(name, ‘(.m$)|(.mdl$)’)

Test can also be a function handle as used in arrayfun/cellfun, e.g. @(f)f.bytes>1024

  • RMPATH

Optional path to remove from beginning of “name” field in returned output. Specified path must be common to all items found.

If RMPATH = 1 or true, path to remove is part of ROOT before the first wildcard.

Outputs

  • D

D is a structure with the same fields as Matlab DIR output.

The “name” field includes the relative path as well as the name to the file that was found. Path can be shorten or ommited when using 3rd argument RMPATH.

  • P

Common path or RMPATH (if specified) for the file list returned in D.

  • Screen output

If not output variable is specified then the output is sent to the screen.

Versions

  • 1.0 - 2009, Gus Brown

  • 2.0 - 26/05/2011 Thomas Vanaret

    No longer exclude all directories from a simple search (no *); Fixing bug on returned path; Exclude “.svn” directories; Extended test possibilies; Subfunctions created;

  • 2.1 - 14/07/2011 Thomas Vanaret

    New argument allowing to remove common path from name; Comments review;

  • 2.2 - 20/12/2011 Thomas Vanaret

    Fixing bug on display with 0b files; Specific display when no file match filter;

  • 2.3 - 19/01/2014 Thomas Vanaret

    Adding improvements suggested by X. Mo : - function handle as TEST input - code optimisation (avoiding loop) Fixing possible bug when using a wildcard at the beginning; Common path as 2nd optionnal output;

Examples

D = rdir(’*.m’);

for ii=1:length(D), disp(D(ii).name); end;

% to find all files in the current directory and sub directories D = rdir(’***’)

% If no output is specified then the files are sent to % the screen. rdir(‘c:program fileswindows *.exe’); rdir(‘c:program fileswindows ***.dll’);

% Using the test function to find files modified today rdir(‘c:win**’,’datenum>floor(now)’); % Using the test function to find files of a certain size rdir(‘c:program fileswin**.exe’,’bytes>1024 & bytes<1048576’); % Using the test function to find files modified in 2011 rdir(‘c:win**’,’strfind(date, ‘’2011’’)’);

% Using the 3rd input to shorten output name rdir([matlabroot, ‘*.txt’], ‘’, ‘C:Program Files') % Using the 3rd input to shorten output name rdir([matlabroot, ‘*.txt’], ‘’, 1)

See also DIR

djtools.readKiloSortOutput(clust, sampleRate)#

output spiketimes and Kilosort ID number

djtools.read_MClust_output(filename)#

reads MClust timestamp output files each “neuron” (or cluster) has its own output file

usage: spiketimes=read_MClust_output(filename) input: filename of .t file in curent directory output: spiketimes in 0.1 ms

mw 12-18-2011

djtools.reportgen_example#

example of Report Generator

djtools.sem(vector_data)#

Recall that s.e.m. = std(x)/sqrt(length(x));

djtools.sha()#

show all figures mw040908

djtools.shadedErrorBar(x, y, errBar, varargin)#

generate continuous error bar area around a line plot

function H=shadedErrorBar(x,y,errBar, …)

Purpose Makes a 2-d line plot with a pretty shaded error bar made using patch. Error bar color is chosen automatically.

Inputs (required) x - vector of x values [optional, can be left empty] y - vector of y values or a matrix of n observations by m cases

where m has length(x);

errBar - if a vector we draw symmetric errorbars. If it has a size

of [2,length(x)] then we draw asymmetric error bars with row 1 being the upper bar and row 2 being the lower bar (with respect to y). ** alternatively ** errBar can be a cellArray of two function handles. The first defines which statistic the line should be and the second defines the error bar.

Inputs (optional, param/value pairs) ‘lineProps’ - [‘-k’ by default] defines the properties of

the data line. e.g.: ‘or-’, or {‘-or’,’markerfacecolor’,[1,0.2,0.2]}

‘transparent’ - [true by default] if true, the shaded error

bar is made transparent. However, for a transparent vector image you will need to save as PDF, not EPS, and set the figure renderer to “painters”. An EPS will only be transparent if you set the renderer to OpenGL, however this makes a raster image.

‘patchSaturation’- [0.2 by default] The saturation of the patch color.

Outputs H - a structure of handles to the generated plot objects.

Examples: y=randn(30,80); x=1:size(y,2);

1) shadedErrorBar(x,mean(y,1),std(y),’lineprops’,’g’);

2) shadedErrorBar(x,y,{@median,@std},’lineprops’,{‘r-o’,’markerfacecolor’,’r’});

3) shadedErrorBar([],y,{@median,@(x) std(x)*1.96},’lineprops’,{‘r-o’,’markerfacecolor’,’k’});

4) Overlay two transparent lines: clf y=randn(30,80)*10; x=(1:size(y,2))-40; shadedErrorBar(x,y,{@mean,@std},’lineprops’,’-r’,’transparent’,1); hold on y=ones(30,1)*x; y=y+0.06*y.^2+randn(size(y))*10; shadedErrorBar(x,y,{@mean,@std},’lineprops’,’-b’,’transparent’,1); hold off

Rob Campbell - November 2009

djtools.simple_clust1()#
djtools.simple_clustBATCH1#

Kip’s batch processing version. Other BS commented out or eliminated

djtools.skillmack(M, treatments, blocks)#
djtools.subplot1(M, N, varargin)#
djtools.textprogressbar(c)#

This function creates a text progress bar. It should be called with a STRING argument to initialize and terminate. Otherwise the number correspoding to progress in % should be supplied. INPUTS: C Either: Text string to initialize or terminate

Percentage number to show progress

OUTPUTS: N/A Example: Please refer to demo_textprogressbar.m

djtools.uigetfile_n_dir(start_path, dialog_title)#

Pick multiple directories and/or files

djtools.xml2struct(file)#

Convert xml file into a MATLAB structure [ s ] = xml2struct( file )

A file containing: <XMLname attrib1=”Some value”>

<Element>Some text</Element> <DifferentElement attrib2=”2”>Some more text</Element> <DifferentElement attrib3=”2” attrib4=”1”>Even more text</DifferentElement>

</XMLname>

Will produce: s.XMLname.Attributes.attrib1 = “Some value”; s.XMLname.Element.Text = “Some text”; s.XMLname.DifferentElement{1}.Attributes.attrib2 = “2”; s.XMLname.DifferentElement{1}.Text = “Some more text”; s.XMLname.DifferentElement{2}.Attributes.attrib3 = “2”; s.XMLname.DifferentElement{2}.Attributes.attrib4 = “1”; s.XMLname.DifferentElement{2}.Text = “Even more text”;

Please note that the following characters are substituted ‘-’ by ‘_dash_’, ‘:’ by ‘_colon_’ and ‘.’ by ‘_dot_’

Written by W. Falkena, ASTI, TUDelft, 21-08-2010 Attribute parsing speed increased by 40% by A. Wanner, 14-6-2011 Added CDATA support by I. Smirnov, 20-3-2012

Modified by X. Mo, University of Wisconsin, 12-5-2012

djtools.xml2struct_old(file)#

Convert xml file into a MATLAB structure [ s ] = xml2struct( file )

A file containing: <XMLname attrib1=”Some value”>

<Element>Some text</Element> <DifferentElement attrib2=”2”>Some more text</Element> <DifferentElement attrib3=”2” attrib4=”1”>Even more text</DifferentElement>

</XMLname>

Will produce: s.XMLname.Attributes.attrib1 = “Some value”; s.XMLname.Element.Text = “Some text”; s.XMLname.DifferentElement{1}.Attributes.attrib2 = “2”; s.XMLname.DifferentElement{1}.Text = “Some more text”; s.XMLname.DifferentElement{2}.Attributes.attrib3 = “2”; s.XMLname.DifferentElement{2}.Attributes.attrib4 = “1”; s.XMLname.DifferentElement{2}.Text = “Even more text”;

Please note that the following characters are substituted ‘-’ by ‘_dash_’, ‘:’ by ‘_colon_’ and ‘.’ by ‘_dot_’

Written by W. Falkena, ASTI, TUDelft, 21-08-2010 Attribute parsing speed increased by 40% by A. Wanner, 14-6-2011 Added CDATA support by I. Smirnov, 20-3-2012

Modified by X. Mo, University of Wisconsin, 12-5-2012