Skip to content

Commit

Permalink
Merge pull request #65 from SilverLabUCL/replace_manifold
Browse files Browse the repository at this point in the history
replace deprecated ImagingPlane parameters
alessandrofelder authored Aug 27, 2020
2 parents c9a2fc8 + 05b2852 commit 3c5816c
Showing 14 changed files with 6,486 additions and 4,722 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ def read(*names, **kwargs):
# eg: 'keyword1', 'keyword2', 'keyword3',
],
install_requires=[
'pynwb==1.2.1',
'pynwb==1.3.2',
'appdirs',
'h5py>=2.7.1',
'hdmf<2.0.0',
35 changes: 13 additions & 22 deletions src/silverlabnwb/nwb_file.py
Original file line number Diff line number Diff line change
@@ -808,15 +808,15 @@ def _write_roi_data(self, all_rois, num_trials, cycles_per_trial,
# Quick fix...
self.nwb_io.close()

def add_imaging_plane(self, name, manifold, description,
def add_imaging_plane(self, name, description, origin_coords, grid_spacing,
green=True, red=True):
"""Add a new imaging plane definition to /general/optophysiology.
:param name: A name for the NWB group representing this imaging plane.
:param manifold: 3d array giving the x,y,z coordinates in microns for each pixel
in the plane. If the plane is really a line, this can be an Nx1x3 array.
:param description: Brief text description of the plane, e.g. "Reference Z stack",
"Pointing mode acquisition sequence".
:param origin_coords: physical location of the first element of the imaging plane
:param grid_spacing: distance along each axis between two adjacent pixels in the plane (assumes a regular grid)
:param green: Whether to include the green channel.
:param red: Whether to include the red channel.
"""
@@ -833,13 +833,6 @@ def add_imaging_plane(self, name, manifold, description,
description='Red channel, typically used for reference.',
emission_lambda=float(opto_metadata['emission_lambda']['red']))
channels.append(channel)
if self.compress:
wrapped_manifold = H5DataIO(data=manifold,
compression='gzip',
compression_opts=4,
)
else:
wrapped_manifold = manifold
for channel in channels:
self.nwb_file.create_imaging_plane(
name="{}_{}".format(name, channel.name),
@@ -850,9 +843,10 @@ def add_imaging_plane(self, name, manifold, description,
imaging_rate=cycle_rate,
indicator=opto_metadata['calcium_indicator'],
location=opto_metadata['location'],
manifold=wrapped_manifold,
unit='metre',
conversion=1e6,
origin_coords=origin_coords,
origin_coords_unit='micrometers',
grid_spacing=grid_spacing,
grid_spacing_unit='micrometers',
reference_frame='TODO: In lab book (partly?)'
)

@@ -876,22 +870,19 @@ def read_zplane(self, zplane_path):
index_col=False)
num_pixels = self.imaging_info.frame_size
plane_width_in_microns = self.imaging_info.field_of_view
template_manifold = np.zeros((num_pixels, num_pixels, 3))
x = np.linspace(0, plane_width_in_microns, num_pixels)
y = np.linspace(0, plane_width_in_microns, num_pixels)
xv, yv = np.meshgrid(x, y)
template_manifold[:, :, 0] = xv
template_manifold[:, :, 1] = yv
self.zplanes = {}
for plane in zplane_data.itertuples():
manifold = template_manifold.copy()
manifold[:, :, 2] = plane.z
name = 'Zstack{:04d}'.format(plane.Index + 1)
self.zplanes[plane.z] = name
# TODO: Is it OK to have 2D spacing with 3D coords (allowed by pynwb, but this doesn't mean it's OK)?
spacing = plane_width_in_microns / (num_pixels - 1)
origin_coords = [0, 0, plane.z]
self.add_imaging_plane(
name=name,
description='Reference Z stack',
manifold=manifold)
origin_coords=origin_coords,
grid_spacing=np.float32([spacing, spacing, 0])
)
ZplanePockelsDatasetClass = get_class('ZplanePockelsDataset', 'silverlab_extended_schema')
self.custom_silverlab_dict['zplane_pockels'] = ZplanePockelsDatasetClass(
columns=zplane_data.columns.tolist(),
696 changes: 402 additions & 294 deletions tests/data/161215_15_34_21.sig2

Large diffs are not rendered by default.

692 changes: 398 additions & 294 deletions tests/data/161215_15_58_52.sig2

Large diffs are not rendered by default.

586 changes: 340 additions & 246 deletions tests/data/161222_16_18_47.sig2

Large diffs are not rendered by default.

1,487 changes: 914 additions & 573 deletions tests/data/170317_10_11_01.sig2

Large diffs are not rendered by default.

1,167 changes: 660 additions & 507 deletions tests/data/170322_14_06_43.sig2

Large diffs are not rendered by default.

2,358 changes: 1,350 additions & 1,008 deletions tests/data/170714_22_26_27.sig2

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions tests/data/metadata_only_B.sig2
Original file line number Diff line number Diff line change
@@ -4,6 +4,12 @@ Generating signature for metadata_only_B.nwb
@.specloc: type=Reference val="->/specifications"
/file_create_date: dtype=ignored shape=ignored val="ignored"
/general/data_collection: dtype=object shape=() val="All about the data."
/general/devices/AOL_microscope
@description: type=str val="Random access 3d acousto-optic lens two-photon microscope"
/general/devices/air_puff_device
@description: type=str val="Delivers an air puff stimulus to the mouse's whiskers"
/general/devices/mouse_wheel_device
@description: type=str val="Records mouse speed data"
/general/experiment_description: dtype=object shape=() val="Experiment description"
/general/experimenter: dtype=object shape=(1,) val="[B Y-S]"
/general/institution: dtype=object shape=() val="University College London"
Loading

0 comments on commit 3c5816c

Please sign in to comment.