Commit 01d501c6 authored by Kim Sontheimer's avatar Kim Sontheimer
Browse files

cleanup, removed checkpoints

parent b291d04c
%% Cell type:code id: tags:
``` python
import sys
print(sys.path)
#sys.path.insert(0, '/home/denker/Projects/toolboxes/py/python-neo')
#sys.path.insert(0, '/home/denker/Projects/toolboxes/py/elephant')
sys.path.insert(0, '/home/denker/Projects/scientific_data_ms_package/code')
import os
import numpy as np
import matplotlib.pyplot as plt
import quantities as pq
from neo import Block, Segment
from neo.io import BlackrockIO
from elephant.signal_processing import butter
from reachgraspio import reachgraspio
from neo_utils import add_epoch, cut_segment_by_epoch, get_events
# Specify the path to the recording session to load, eg, '/home/user/l101210-001'
session_name = '/home/denker/SciDataPubDatasets/DataNikos2/i140703-001'
odml_dir = '/home/denker/SciDataPubDatasets/MetaDataNikos2/odMLfiles'
```
%% Output
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-801d98b34a28> in <module>()
13 from neo import Block, Segment
14 from neo.io import BlackrockIO
---> 15 from elephant.signal_processing import butter
16
17 from reachgraspio import reachgraspio
ImportError: No module named 'elephant'
%% Cell type:markdown id: tags:
# Open the session for reading
%% Cell type:code id: tags:
``` python
#session = BlackrockIO(session_name)
session = reachgraspio.ReachGraspIO(session_name, odml_directory=odml_dir)
```
%% Cell type:markdown id: tags:
Read the first 300s of data (time series at 1000Hz (ns2) and 30kHz (ns6)
scaled to units of voltage, sorted spike trains, spike waveforms and events)
from electrode 62 of the recording session and return it as a Neo Block. The
time shift of the ns2 signal (LFP) induced by the online filter is
automatically corrected for by a heuristic factor stored in the metadata
(correct_filter_shifts=True).
%% Cell type:code id: tags:
``` python
data_block = session.read_block(
nsx_to_load='all',
n_starts=None, n_stops=300 * pq.s,
channels=[62], units='all',
load_events=True, load_waveforms=True, scaling='voltage')
# Access the single Segment of the data block, reaching up to 300s.
assert len(data_block.segments) == 1
data_segment = data_block.segments[0]
```
%% Cell type:code id: tags:
``` python
print "Block: ", data_block.name
print data_block.annotations
print
print "Segment: ", data_segment.name
print data_segment.annotations
print
print "A Spiketrain: "
print data_segment.spiketrains[0][0:10]
print data_segment.spiketrains[0][0:10].rescale(pq.ms)
print data_segment.spiketrains[0][0:10].magnitude
print data_segment.spiketrains[0].t_start
print data_segment.spiketrains[0].t_stop
print data_segment.spiketrains[0].annotations
print
print "An AnalogSignal: "
print data_segment.analogsignals[0].times[0:10]
print data_segment.analogsignals[0][0:10]
print data_segment.analogsignals[0].annotations
print
print "An Event: "
print data_segment.events[0].times[0:10]
print data_segment.events[0].labels[0:10]
print [data_segment.events[0].annotations[x][0:10] if type(data_segment.events[0].annotations[x]) is list else data_segment.events[0].annotations[x] for x in data_segment.events[0].annotations]
print
```
%% Output
Block: Reachgrasp Recording Data Block
{'arraygrid_col_num': 10, 'project_name': u'reach-to-grasp', 'arraygrids_tot_num': 1, 'avail_file_set': ['ccf', 'odml', 'nev', 'ns2', 'ns6'], 'subject_name': u'monkey_N', 'electrodes_pitch': array(400.0) * um, 'rec_pauses': False, 'subject_birthday': datetime.date(2008, 5, 17), 'project_type': u'electrophysiology', 'avail_nsx': [2, 6], 'avail_electrode_ids': [-1, 81, 83, 85, 88, 90, 92, 93, 96, -1, 79, 80, 84, 86, 87, 89, 91, 94, 63, 95, 77, 78, 82, 49, 53, 55, 57, 59, 61, 32, 75, 76, 45, 47, 51, 56, 58, 60, 64, 30, 73, 74, 41, 43, 44, 46, 52, 62, 31, 28, 71, 72, 39, 40, 42, 50, 54, 21, 29, 26, 69, 70, 37, 38, 48, 15, 19, 25, 27, 24, 67, 68, 35, 36, 5, 17, 13, 23, 20, 22, 65, 66, 33, 34, 7, 9, 11, 12, 16, 18, -1, 2, 1, 3, 4, 6, 8, 10, 14, -1], 'electrodes_tot_num': 100, 'setup_location': u'Inst. de Neurosciences de la Timone (INT), UMR 7289, CNRS - Aix Marseille Univ., Marseille, France', 'project_subtype': u'motor behavior', 'taskdesigns': [u'TwoCues'], 'array_serialnum': u'8596-001139', 'avail_nev': True, 'nb_segments': 1, 'subject_activehand': u'left', 'avail_ccf': True, 'connector_type': u'CerePort', 'arraygrid_row_num': 10, 'conditions': [1], 'subject_gender': u'male', 'avail_sif': False}
Segment: Segment 0
{'condition': 1}
A Spiketrain:
[ 16471. 21599. 58494. 65345. 76005. 90368. 110354. 112677.
112969. 113317.] (1.0/30000 * s)
[ 549.03333333 719.96666667 1949.8 2178.16666667 2533.5
3012.26666667 3678.46666667 3755.9 3765.63333333 3777.23333333] ms
[ 16471. 21599. 58494. 65345. 76005. 90368. 110354. 112677.
112969. 113317.]
0.0 (1.0/30000 * s)
9000000.0 (1.0/30000 * s)
{'channel_id': 62, 'noise': True, 'electrode_reject_IFC': False, 'sua': False, 'electrode_reject_HFC': False, 'mua': False, 'connector_aligned_id': 48, 'electrode_reject_LFC': False, 'unit_id': 0}
An AnalogSignal:
[-2.1 -1.1 -0.1 0.9 1.9 2.9 3.9 4.9 5.9 6.9] (1.0/1000.0*s)
[[ 42.25]
[ 5.5 ]
[ -5.25]
[ 2. ]
[ 3.5 ]
[ -4.5 ]
[ -6.25]
[ -2. ]
[ -4. ]
[ -8.5 ]] uV
{'filter_lo_pass_freq': array(250.0) * Hz, 'filter_shift_correction': array(2.1) * ms, 'electrode_reject_HFC': False, 'filter_lo_pass_order': 4, 'filter_hi_pass_freq': array(0.3) * Hz, 'connector_aligned_id': 48, 'electrode_reject_LFC': False, 'filter_type': u'butterworth', 'nsx': 2, 'channel_id': 62, 'electrode_reject_IFC': False, 'filter_hi_pass_order': 1}
An Event:
[ 39424. 51491. 63532. 72614. 102672. 108766. 136071. 144917.
144918. 213943.] (1.0/30000 * s)
['65296' '65360' '65370' '65360' '65366' '65382' '65514' '65386' '65312'
'65296']
[[False, False, False, False, False, False, False, False, False, False], ['TS-ON', 'WS-ON', 'CUE-ON', 'CUE-OFF', 'GO-ON', 'SR', 'RW-ON', 'RW-OFF', 'STOP', 'TS-ON'], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [False, False, False, False, False, False, False, False, False, False], [True, True, True, True, True, True, True, True, True, False], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2], ['SGHF', 'SGHF', 'SGHF', 'SGHF', 'SGHF', 'SGHF', 'SGHF', 'SGHF', 'SGHF', 'SGHF'], [39424, 39424, 39424, 39424, 39424, 39424, 39424, 39424, 39424, 213943]]
%% Cell type:markdown id: tags:
# Construct analysis epochs
In this step we extract and cut the data into time segments (termed analysis
epochs) that we wish to analyze. We contrast these analysis epochs to the
behavioral trials that are defined by the experiment as occurrence of a Trial
Start (TS-ON) event in the experiment. Concretely, here our analysis epochs
are constructed as a cutout of 25ms of data around the TS-ON event of all
successful behavioral trials.
Get Trial Start (TS-ON) events of all successful behavioral trials
(corresponds to performance code 255, which is accessed for convenience and
better legibility in the dictionary attribute performance_codes of the
ReachGraspIO class).
To this end, we filter all event objects of the loaded data to match the name
"TrialEvents", which is the Event object containing all Events available (see
documentation of ReachGraspIO). From this Event object we extract only events
matching "TS-ON" and the desired trial performance code (which are
annotations of the Event object).
%% Cell type:code id: tags:
``` python
start_events = get_events(
data_segment,
properties={
'name': 'TrialEvents',