Skip to content

Commit

Permalink
Improve intro tutorial (#633)
Browse files Browse the repository at this point in the history
Remove duplicate code
Use consistent variable naming

Co-authored-by: Ben Dichter <[email protected]>
  • Loading branch information
ehennestad and bendichter authored Nov 25, 2024
1 parent da75e95 commit f82e559
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 51 deletions.
273 changes: 239 additions & 34 deletions tutorials/html/intro.html

Large diffs are not rendered by default.

Binary file modified tutorials/intro.mlx
Binary file not shown.
31 changes: 14 additions & 17 deletions tutorials/private/mcode/intro.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@
%
% Note: These diagrams follow a standard convention called "UML class diagram"
% to express the object-oriented relationships between NWB classes. For our purposes,
% all you need to know is that an open triangle means "extends" and an open diamond
% means "is contained within." Learn more about class diagrams on <https://en.wikipedia.org/wiki/Class_diagram
% the wikipedia page>.
% all you need to know is that an open triangle means "extends" (i.e., is a specialized
% subtype of), and an open diamond means "is contained within." Learn more about
% class diagrams on <https://en.wikipedia.org/wiki/Class_diagram the wikipedia
% page>.
%
% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html
% |*SpatialSeries*|> is a subclass of <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/TimeSeries.html
Expand All @@ -149,13 +150,7 @@
);

% create Position object and add SpatialSeries
Position = types.core.Position('SpatialSeries', spatial_series_ts);

% create processing module
behavior_mod = types.core.ProcessingModule('description', 'contains behavioral data');

% add the Position object (that holds the SpatialSeries object)
behavior_mod.nwbdatainterface.set('Position', Position);
position = types.core.Position('SpatialSeries', spatial_series_ts);
%%
% NWB differentiates between raw, _acquired_ data, which should never change,
% and _processed_ data, which are the results of preprocessing algorithms and
Expand All @@ -171,14 +166,14 @@
% |*Position*|> object to the module.

% create processing module
behavior_mod = types.core.ProcessingModule('description', 'contains behavioral data');
behavior_module = types.core.ProcessingModule('description', 'contains behavioral data');

% add the Position object (that holds the SpatialSeries object) to the
% module and name the Position object "Position"
behavior_mod.nwbdatainterface.set('Position', Position);
% add the Position object (that holds the SpatialSeries object) to the module
% and name the Position object "Position"
behavior_module.nwbdatainterface.set('Position', position);

% add the processing module to the NWBFile object, and name the processing module "behavior"
nwb.processing.set('behavior', behavior_mod);
nwb.processing.set('behavior', behavior_module);
% Trials
% Trials are stored in a <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/TimeIntervals.html
% |*TimeIntervals*|> object which is a subclass of <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+hdmf_common/DynamicTable.html
Expand Down Expand Up @@ -207,7 +202,7 @@
trials.addRow('start_time', 1.5, 'stop_time', 2.0, 'correct', true)
trials.addRow('start_time', 2.5, 'stop_time', 3.0, 'correct', false)

trials.toTable() % visualize the table
trials.toTable() % visualize the table
nwb.intervals_trials = trials;

% If you have multiple trials tables, you will need to use custom names for
Expand Down Expand Up @@ -268,4 +263,6 @@
% Optical physiology>
%%
% See the <https://neurodatawithoutborders.github.io/matnwb/doc/index.html API
% documentation> to learn what data types are available.
% documentation> to learn what data types are available.
%
%

0 comments on commit f82e559

Please sign in to comment.