-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tutorial reproducing new icephys tables
- Loading branch information
1 parent
486e063
commit ecd693b
Showing
1 changed file
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,299 @@ | ||
session_start_time = datetime(2018, 3, 1, 12, 0, 0, 'TimeZone', 'local'); | ||
|
||
|
||
nwbfile = NwbFile( ... | ||
'session_description', 'my first synthetic recording', ... | ||
'identifier', 'EXAMPLE_ID', ... | ||
'session_start_time', session_start_time, ... | ||
'general_experimenter', 'Dr. Bilbo Baggins', ... | ||
'general_lab', 'Bag End Laboratory', ... | ||
'general_institution', 'University of Middle Earth at the Shire', ... | ||
'general_experiment_description', 'I went on an adventure with thirteen dwarves to reclaim vast treasures.', ... | ||
'general_session_id', 'LONELYMTN' ... | ||
); | ||
|
||
device_name = 'Heka ITC-1600'; | ||
device_link = types.untyped.SoftLink(['/general/devices/' device_name]); | ||
|
||
nwbfile.general_devices.set(device_name, types.core.Device()); | ||
|
||
electrode_name = 'ele0'; | ||
electrode_link = types.untyped.SoftLink( ... | ||
['/general/intracellular_ephys/' electrode_name] ... | ||
); | ||
|
||
electrode_object_view = types.untyped.ObjectView( .... | ||
['/general/intracellular_ephys/' electrode_name] ... | ||
); | ||
|
||
nwbfile.general_intracellular_ephys.set( .... | ||
electrode_name, types.core.IntracellularElectrode( ... | ||
'description', 'a mock intracellular electrode', ... | ||
'device', device_link) ... | ||
); | ||
|
||
nwbfile.stimulus_presentation.set( ... | ||
'ccss', types.core.VoltageClampStimulusSeries( ... | ||
'data', [1, 2, 3, 4, 5], ... | ||
'starting_time', 123.6, ... | ||
'starting_time_rate', 10e3, ... | ||
'electrode', electrode_link, ... | ||
'gain', 0.02, ... | ||
'sweep_number', uint64(15), ... | ||
'stimulus_description', 'N/A' ... | ||
) ... | ||
); | ||
|
||
nwbfile.acquisition.set( ... | ||
'vcs', types.core.VoltageClampSeries( ... | ||
'data', [0.1, 0.2, 0.3, 0.4, 0.5], ... | ||
'data_conversion', 1e-12, ... | ||
'data_resolution', NaN, ... | ||
'starting_time', 123.6, ... | ||
'starting_time_rate', 20e3, ... | ||
'electrode', electrode_link, ... | ||
'gain', 0.02, ... | ||
'capacitance_slow', 100e-12, ... | ||
'resistance_comp_correction', 70.0, ... | ||
'stimulus_description', 'N/A', ... | ||
'sweep_number', uint64(15) ... | ||
) ... | ||
); | ||
|
||
|
||
%% | ||
ic_rec_table = types.core.IntracellularRecordingsTable( ... | ||
'categories', {'electrodes', 'stimiuli', 'responses'}, ... | ||
'colnames', {'recordings_tag'}, ... | ||
'description', [ ... | ||
'A table to group together a stimulus and response from a single ', ... | ||
'electrode and a single simultaneous recording and for storing ', ... | ||
'metadata about the intracellular recording.'], ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64([10, 11, 12]) ... | ||
) ... | ||
); | ||
|
||
ic_rec_table.electrodes = types.core.IntracellularElectrodesTable( ... | ||
'description', 'Table for storing intracellular electrode related metadata.', ... | ||
'colnames', {'electrode'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64([0, 1, 2]) ... | ||
), ... | ||
'electrode', types.hdmf_common.VectorData( ... | ||
'data', repmat(electrode_object_view, 3, 1), ... | ||
'description', 'Column for storing the reference to the intracellular electrode' ... | ||
) ... | ||
); | ||
|
||
ic_rec_table.responses = types.core.IntracellularResponsesTable( ... | ||
'description', 'Table for storing intracellular response related metadata.', ... | ||
'colnames', {'response'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64([0, 1, 2]) ... | ||
), ... | ||
'response', types.core.TimeSeriesReferenceVectorData( ... | ||
'description', 'Column storing the reference to the recorded response for the recording (rows)', ... | ||
'data', struct( ... | ||
'idx_start', [0, 2, 0], ... | ||
'count', [5, 3, 5], ... | ||
'timeseries', [ ... | ||
types.untyped.ObjectView('/acquisition/vcs'), ... | ||
types.untyped.ObjectView('/acquisition/vcs'), ... | ||
types.untyped.ObjectView('/acquisition/vcs') ... | ||
] ... | ||
)... | ||
)... | ||
); | ||
|
||
|
||
ic_rec_table.stimuli = types.core.IntracellularStimuliTable( ... | ||
'description', 'Table for storing intracellular stimulus related metadata.', ... | ||
'colnames', {'stimulus'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64([0, 1, 2]) ... | ||
), ... | ||
'stimulus', types.core.TimeSeriesReferenceVectorData( ... | ||
'description', 'Column storing the reference to the recorded stimulus for the recording (rows)', ... | ||
'data', struct( ... | ||
'idx_start', [0, 1, -1], ... | ||
'count', [5, 3, -1], ... | ||
'timeseries', [ ... | ||
types.untyped.ObjectView('/stimulus/presentation/ccss'), ... | ||
types.untyped.ObjectView('/stimulus/presentation/ccss'), ... | ||
types.untyped.ObjectView('/acquisition/vcs') ... | ||
] ... | ||
)... | ||
)... | ||
); | ||
|
||
% add category | ||
ic_rec_table.categories = [ic_rec_table.categories, {'recording_lab_data'}]; | ||
ic_rec_table.dynamictable.set( ... | ||
'recording_lab_data', types.hdmf_common.DynamicTable( ... | ||
'description', 'category table for lab-specific recording metadata', ... | ||
'colnames', {'location'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64([0, 1, 2]) ... | ||
), ... | ||
'location', types.hdmf_common.VectorData( ... | ||
'data', {'Mordor', 'Gondor', 'Rohan'}, ... | ||
'description', 'Recording location in Middle Earth' ... | ||
) ... | ||
) ... | ||
); | ||
|
||
% Add voltage threshold as column of electrodes table | ||
ic_rec_table.electrodes.colnames = [ic_rec_table.electrodes.colnames {'voltage_threshold'}]; | ||
ic_rec_table.electrodes.vectordata.set('voltage_threshold', types.hdmf_common.VectorData( ... | ||
'data', [0.1, 0.12, 0.13], ... | ||
'description', 'Just an example column on the electrodes category table' ... | ||
) ... | ||
); | ||
|
||
nwbfile.general_intracellular_ephys_intracellular_recordings = ic_rec_table; | ||
|
||
|
||
%% Add a simultaneous recording | ||
|
||
% create simultaneous recordings table with custom column | ||
% 'simultaneous_recording_tag' | ||
ic_sim_recs_table = types.core.SimultaneousRecordingsTable( ... | ||
'description', [ ... | ||
'A table for grouping different intracellular ', ... | ||
'recordings from theIntracellularRecordingsTable table together ', ... | ||
'that were recorded simultaneously from different electrodes.'... | ||
], ... | ||
'colnames', {'recordings', 'simultaneous_recording_tag'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64(12) ... | ||
), ... | ||
'recordings', types.hdmf_common.DynamicTableRegion( ... | ||
'table', types.untyped.ObjectView( ... | ||
'/general/intracellular_ephys/intracellular_recordings' ... | ||
), ... | ||
'data', [0, 1, 2], ... | ||
'description', [ | ||
'Column with references to one or more rows in ', ... | ||
'the IntracellularRecordingsTable table' | ||
] ... | ||
), ... | ||
'recordings_index', types.hdmf_common.VectorIndex( ... | ||
'description', 'Index for VectorData "recordings"', ... | ||
'target', types.untyped.ObjectView( ... | ||
'/general/intracellular_ephys/simultaneous_recordings/recordings' ... | ||
), ... | ||
'data', 3 ... | ||
), ... | ||
'simultaneous_recording_tag', types.hdmf_common.VectorData( ... | ||
'description', 'A custom tag for simultaneous_recordings', ... | ||
'data', {'LabTag1'} ... | ||
) ... | ||
); | ||
|
||
% add a column | ||
ic_sim_recs_table.colnames = [ic_sim_recs_table.colnames, {'simultaneous_recording_type'}]; | ||
ic_sim_recs_table.vectordata.set( ... | ||
'simultaneous_recording_type', types.hdmf_common.VectorData(... | ||
'description', 'Description of the type of simultaneous_recording', ... | ||
'data', {'SimultaneousRecordingType1'} ... | ||
) ... | ||
); | ||
|
||
nwbfile.general_intracellular_ephys_simultaneous_recordings = ic_sim_recs_table; | ||
|
||
%% add sequential recording | ||
|
||
nwbfile.general_intracellular_ephys_sequential_recordings = types.core.SequentialRecordingsTable( ... | ||
'description', [ ... | ||
'A table for grouping different intracellular recording ', ... | ||
'simultaneous_recordings from the SimultaneousRecordingsTable ', ... | ||
'table together. This is typically used to group together ', ... | ||
'simultaneous_recordings where the a sequence of stimuli of ', ... | ||
'the same type with varying parameters have been presented in ', ... | ||
'a sequence.' ... | ||
], ... | ||
'colnames', {'simultaneous_recordings', 'stimulus_type'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64(15) ... | ||
), ... | ||
'simultaneous_recordings', types.hdmf_common.DynamicTableRegion( ... | ||
'table', types.untyped.ObjectView('/general/intracellular_ephys/simultaneous_recordings'), ... | ||
'description', [ ... | ||
'Column with references to one or more rows in the ', ... | ||
'SimultaneousRecordingsTable table', ... | ||
], ... | ||
'data', 0 ... | ||
), ... | ||
'simultaneous_recordings_index', types.hdmf_common.VectorIndex( ... | ||
'target', types.untyped.ObjectView( ... | ||
'/general/intracellular_ephys/sequential_recordings/simultaneous_recordings' ... | ||
), ... | ||
'description', 'Index for VectorData "simultaneous_recordings"', ... | ||
'data', 1 ... | ||
), ... | ||
'stimulus_type', types.hdmf_common.VectorData( ... | ||
'description', 'Column storing the type of stimulus used for the sequential recording', ... | ||
'data', {'square'} ... | ||
) ... | ||
); | ||
|
||
|
||
%% add repetition | ||
|
||
nwbfile.general_intracellular_ephys_repetitions = types.core.RepetitionsTable( ... | ||
'description', [ ... | ||
'A table for grouping different intracellular recording sequential ', ... | ||
'recordings together. With each SimultaneousRecording typically ', ... | ||
'representing a particular type of stimulus, the RepetitionsTable ', ... | ||
'table is typically used to group sets of stimuli applied in sequence.' ... | ||
], ... | ||
'colnames', {'sequential_recordings'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64(17) ... | ||
), ... | ||
'sequential_recordings', types.hdmf_common.DynamicTableRegion( ... | ||
'table', types.untyped.ObjectView('/general/intracellular_ephys/sequential_recordings'), ... | ||
'description', 'Column with references to one or more rows in the SequentialRecordingsTable table', ... | ||
'data', 0 ... | ||
), ... | ||
'sequential_recordings_index', types.hdmf_common.VectorIndex( ... | ||
'target', types.untyped.ObjectView('/general/intracellular_ephys/repetitions/sequential_recordings'), ... | ||
'description', 'Index for VectorData "sequential_recordings"', ... | ||
'data', 1 ... | ||
) ... | ||
); | ||
|
||
%% add experimental condition | ||
|
||
nwbfile.general_intracellular_ephys_experimental_conditions = types.core.ExperimentalConditionsTable( ... | ||
'description', [ ... | ||
'A table for grouping different intracellular recording ', ... | ||
'repetitions together that belong to the same experimental ', ... | ||
'conditions.' ... | ||
], ... | ||
'colnames', {'repetitions', 'tag'}, ... | ||
'id', types.hdmf_common.ElementIdentifiers( ... | ||
'data', int64([19, 21]) ... | ||
), ... | ||
'repetitions', types.hdmf_common.DynamicTableRegion( ... | ||
'table', types.untyped.ObjectView('/general/intracellular_ephys/repetitions'), ... | ||
'description', 'Column with references to one or more rows in the RepetitionsTable table', ... | ||
'data', [0, 0] ... | ||
), ... | ||
'repetitions_index', types.hdmf_common.VectorIndex( ... | ||
'target', types.untyped.ObjectView('/general/intracellular_ephys/experimental_conditions/repetitions'), ... | ||
'description', 'Index for VectorData "repetitions"', ... | ||
'data', [1, 2] ... | ||
), ... | ||
'tag', types.hdmf_common.VectorData( ... | ||
'description', 'integer tag for a experimental condition', ... | ||
'data', [1,3] ... | ||
) ... | ||
); | ||
|
||
%% write | ||
nwbExport(nwbfile, 'test_new_icephys.nwb'); | ||
|
||
|
||
|