Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
444c9b1
Add a new version for the latest LabView setup
ageorgou Sep 7, 2020
b7a2f35
Split off reading of ROI table
ageorgou Sep 7, 2020
c34dffb
Start generalising ROI reader
ageorgou Sep 8, 2020
f8a2702
Allow creating ROI readers for newest LabView
ageorgou Sep 8, 2020
84826e3
Start differentiating for variable ROIs
ageorgou Sep 8, 2020
2745018
add new columns
alessandrofelder Sep 17, 2020
7555463
function call to _imaging_section needed
alessandrofelder Sep 18, 2020
f3f86c8
create simple test for ROI reader
alessandrofelder Sep 18, 2020
55c6228
move FIXME to subclass
alessandrofelder Sep 18, 2020
fab0491
add v300 ROI.dat
alessandrofelder Sep 18, 2020
c22913c
adapt to possible lack of speed data file
alessandrofelder Oct 5, 2020
4fb9626
update signatures
alessandrofelder Oct 5, 2020
e958e13
clarify classname to cover all modern versions
alessandrofelder Oct 5, 2020
cb0e263
fix typo in comments
alessandrofelder Oct 5, 2020
187c3e3
wip:add functionality for variable rois
alessandrofelder Oct 5, 2020
3324c94
Use array for ROI sizes for easier computations
ageorgou Oct 11, 2020
f56f713
move reading of roi file
alessandrofelder Oct 14, 2020
1276a6d
accommodate timings.py to variable size rois
alessandrofelder Oct 14, 2020
613731d
fix small bug
alessandrofelder Oct 15, 2020
375cf7e
fix isort
alessandrofelder Oct 15, 2020
b278687
Don't overwrite other readers' attributes!
ageorgou Oct 16, 2020
c07fc67
Check for pointing mode directly in RoiReader
ageorgou Oct 16, 2020
270d9d3
Avoid repetition, use new columns for all v3.0.0
ageorgou Oct 16, 2020
8db9623
Tidy up some epochs/trials things
ageorgou Nov 7, 2020
16ee127
Use each ROI's limits in its dedicated plane
ageorgou Nov 8, 2020
2a9c3ea
Fix some things to get variable ROI import working
ageorgou Nov 12, 2020
0104d79
Add a test with variable resolution
ageorgou Nov 12, 2020
3528285
Cast some ROI data earlier
ageorgou Nov 7, 2020
9afe882
Update datasets to int in some signatures
ageorgou Nov 11, 2020
2d8c99a
Avoid some deprecation warnings
ageorgou Nov 8, 2020
badb3cf
Update latest signature changes for Travis
ageorgou Nov 13, 2020
8115f8f
update signatures for some large files
alessandrofelder Nov 13, 2020
023f0f7
wip: getting roi dimensions right
alessandrofelder Nov 16, 2020
a06b2a9
wip:futile attempts at accounting for angle or not
alessandrofelder Nov 16, 2020
813224f
cast Pixels per ROI correctly
alessandrofelder Nov 16, 2020
0e6f167
wip: passes MatLab comparison...
alessandrofelder Nov 16, 2020
2416aa0
fix bug in add_rois, remove (possibly) unnecessary get_x_y_range func…
alessandrofelder Nov 16, 2020
c62d19c
fix missing newline
alessandrofelder Nov 16, 2020
48d4a3f
minor simplification/clarifications
alessandrofelder Nov 17, 2020
5b524c7
restore get_x_y_range because needed for pixel mask
alessandrofelder Nov 17, 2020
ddbd952
update variable-roi signature
alessandrofelder Nov 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions src/silverlabnwb/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
class LabViewVersions(Enum):
pre2018 = "pre-2018 (original)"
v231 = "2.3.1"
v300 = "3.0.0"

@property
def is_legacy(self):
"""Return whether this version should trigger legacy behaviour."""
return self is self.pre2018


class LabViewHeader(metaclass=abc.ABCMeta):
Expand Down Expand Up @@ -63,6 +69,8 @@ def from_file(cls, filename):
else:
if version == '2.3.1':
return LabViewHeader231(fields, parsed_fields)
elif version == '3.0.0':
return LabViewHeader300(fields, parsed_fields)
else:
raise ValueError('Unsupported LabView version {}.'.format(version))

Expand Down Expand Up @@ -140,6 +148,11 @@ def get_raw_fields(self):
"""
return self._raw_fields

@property
def allows_variable_rois(self):
"""Check whether ROIs with variable shape or resolution are allowed."""
return False # by default (in older versions), they are not


class LabViewHeaderPre2018(LabViewHeader):

Expand Down Expand Up @@ -170,7 +183,7 @@ def _imaging_section(self):
return self["GLOBAL PARAMETERS"]


class LabViewHeader231(LabViewHeader):
class LabViewHeaderPost2018(LabViewHeader):

property_names = {
"frame_size": "Frame Size",
Expand All @@ -182,18 +195,14 @@ class LabViewHeader231(LabViewHeader):
"gain_green": "pmt 2",
}

# In this version of LabView, the trial times are stored in their own
# In these versions of LabView, the trial times are stored in their own
# (misleadingly titled) section of the header.
trial_times_section = 'Intertrial FIFO Times'

def __init__(self, fields, processed_fields):
super().__init__(fields, processed_fields)
self._parse_trial_times()

@property
def version(self):
return LabViewVersions.v231

def _determine_imaging_mode(self):
volume_imaging = self['IMAGING MODES']['Volume Imaging']
functional_imaging = self['IMAGING MODES']['Functional Imaging']
Expand All @@ -216,8 +225,8 @@ def _determine_imaging_mode(self):
' or "Functional Imaging" must be true.')

def _imaging_section(self):
# In LabView version 2.3.1, imaging parameters are stored under the
# relevant imaging mode section.
# In LabView version 2.3.1 and newer, imaging parameters are stored
# under the relevant imaging mode section.
imaging_section_name = ("VOLUME IMAGING"
if self.imaging_mode is Modes.volume
else "FUNCTIONAL IMAGING")
Expand Down Expand Up @@ -253,3 +262,20 @@ def determine_trial_times(self):
end = None # determine final 'end' later from speed data
trial_times.append((start, end))
return trial_times


class LabViewHeader231(LabViewHeaderPost2018):
@property
def version(self):
return LabViewVersions.v231


class LabViewHeader300(LabViewHeaderPost2018):
@property
def version(self):
return LabViewVersions.v300

@property
def allows_variable_rois(self):
return (self._imaging_section()['Variable Length'] == 'TRUE'
or self._imaging_section()['Variable Resolution'] == 'TRUE')
8 changes: 4 additions & 4 deletions src/silverlabnwb/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Handles loading the metadata YAML files.
'''

import collections
import collections.abc
import os

import appdirs
Expand Down Expand Up @@ -71,7 +71,7 @@ def beautify_comment(comment_token):
def read_comments(settings):
comments = {}
for k, v in settings.items():
if isinstance(v, collections.Mapping):
if isinstance(v, collections.abc.Mapping):
comments[k] = read_comments(v)
elif isinstance(v, list):
comments[k] = [read_comments(entry) for entry in v]
Expand Down Expand Up @@ -121,7 +121,7 @@ def recursive_dict_update(base_settings, new_settings):
recursive base_settings.update(new_settings).
"""
for k, v in new_settings.items():
if isinstance(v, collections.Mapping):
if isinstance(v, collections.abc.Mapping):
base_settings[k] = recursive_dict_update(base_settings.get(k, {}), v)
else:
base_settings[k] = new_settings[k]
Expand All @@ -138,7 +138,7 @@ def strip_strings(settings):
for k, v in settings.items():
if isinstance(v, str):
result[k] = v.strip()
elif isinstance(v, collections.Mapping):
elif isinstance(v, collections.abc.Mapping):
result[k] = strip_strings(v)
else:
result[k] = v
Expand Down
5 changes: 5 additions & 0 deletions src/silverlabnwb/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ people:
Harsha:
name: Harsha Gurnani
orcid: 0000-0001-6383-3104
Sameer:
name: Sameer Punde


experiments:
Expand Down Expand Up @@ -114,4 +116,7 @@ sessions:
Harsha: # Should match a user id in the 'people' section
description: One or two sentences describing the experiment and data in the file.
experiment: template # Should match an experiment defined above
Sameer: # Should match a user id in the 'people' section
description: One or two sentences describing the experiment and data in the file.
experiment: template # Should match an experiment defined above

Loading