Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: toTable method does not work on PlaneSegmentation objects #576

Open
2 tasks done
ehennestad opened this issue Jun 25, 2024 · 2 comments · Fixed by #590
Open
2 tasks done

[Bug]: toTable method does not work on PlaneSegmentation objects #576

ehennestad opened this issue Jun 25, 2024 · 2 comments · Fixed by #590
Assignees

Comments

@ehennestad
Copy link
Collaborator

What happened?

toTable method does not work on PlaneSegmentation objects

Steps to Reproduce

% generate fake image_mask data
imaging_shape = [100, 100];
x = imaging_shape(1);
y = imaging_shape(2);

n_rois = 20;
image_mask = zeros(y, x, n_rois);
for i = 1:n_rois
    start = randi(90,2,1);
    image_mask(start(1):start(1)+10, start(2):start(2)+10, 1) = 1;
end

% add data to NWB structures
plane_segmentation = types.core.PlaneSegmentation( ...
    'colnames', {'image_mask'}, ...
    'description', 'output from segmenting my favorite imaging plane', ...
    'id', types.hdmf_common.ElementIdentifiers('data', int64(0:19)'), ...
    'image_mask', types.hdmf_common.VectorData('data', image_mask, 'description', 'image masks') ...
);

Error Message

Error using tabular/horzcat
All tables being horizontally concatenated must have the same number of rows.

Error in matnwb.types.util.dynamictable.nwbToTable (line 81)
matlabTable = [matlabTable DynamicTable.getRow( ...

Error in matnwb.types.hdmf_common.DynamicTable/toTable (line 124)
        table = matnwb.types.util.dynamictable.nwbToTable(obj, varargin{:});

Operating System

macOS

Matlab Version

MATLAB_R2023

Code of Conduct

@ehennestad
Copy link
Collaborator Author

ehennestad commented Jun 25, 2024

Proposed fix:
Permute arrays so that the last dimension of the array becomes the first dimension. This is needed for image masks, because a w x h x nRois sized array needs to be reshaped into nRois rows of a table and in order for this to work, the "nRois" dimension needs to come first.

The fix needs to happen in this function:
+types/+util/+dynamictable/getRow.m

@ehennestad
Copy link
Collaborator Author

Reopening this issue as the fix needs to apply to 2D matrices as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant