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

Allow utils._subsampling to accept ndarray #20

Merged
merged 3 commits into from
Feb 19, 2021

Conversation

notZaki
Copy link
Collaborator

@notZaki notZaki commented Jan 7, 2021

The current subsampling function only works for 3d arrays. This PR allows it to work for arbitrary number of dimensions and brings us closer to supporting 2D data as inputs (#5).

Notes:

  • The function returns a view, so it is possible to mutate the input data
    • It doesn't look like the current code is doing any mutating/in-place operations, but we could return a copy to be safe

@tsalo
Copy link
Member

tsalo commented Jan 11, 2021

The subsampling is performed across voxels though, right? So would subsampling a flattened SxT array really be equivalent to subsampling an XxYxZxT array?

@notZaki
Copy link
Collaborator Author

notZaki commented Jan 11, 2021

Subsampling a flattened array would not be equal to subsampling the original array. This is why the PR doesn't use flattening.

@eurunuela
Copy link
Collaborator

I would like to check how the original code does the subsampling for 2D. The original GIFT code supports 1D, 2D and 3D data for maPCA. However, we only took the 3D part for tedana. Maybe we should translate the 1D and 2D options directly from GIFT and then work on optimizing the code.

What do you guys think?

@notZaki
Copy link
Collaborator Author

notZaki commented Jan 13, 2021

The original GIFT implementation has additional if-statements to support 1D and 2D data: https://github.com/trendscenter/gift/blob/8f22c6078071f93bd5972ae37df3742f17631e9f/GroupICATv4.0c/icatb/icatb_estimate_dimension.m#L379-L396
In modern matlab, the built-in downsample could've been used as an alternative.

I'm not sure what the advantage would be of translating the GIFT code vs using the proposed slices.

@eurunuela
Copy link
Collaborator

I'm not sure what the advantage would be of translating the GIFT code vs using the proposed slices.

The slices approach you proposed is much simpler imo. We could check if both approaches do the same and then stick to the slices one for simplicity.

@codecov-io
Copy link

Codecov Report

Merging #20 (95ce55a) into main (67ad715) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #20      +/-   ##
==========================================
- Coverage   92.09%   92.01%   -0.09%     
==========================================
  Files           3        3              
  Lines         291      288       -3     
==========================================
- Hits          268      265       -3     
  Misses         23       23              
Impacted Files Coverage Δ
mapca/utils.py 98.57% <100.00%> (-0.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67ad715...95ce55a. Read the comment docs.

Copy link
Collaborator

@eurunuela eurunuela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @notZaki !

@eurunuela
Copy link
Collaborator

@tsalo are you okay with merging this PR?

@tsalo
Copy link
Member

tsalo commented Feb 19, 2021

Sorry for the massive delay! Merging now.

@tsalo tsalo merged commit aca3176 into ME-ICA:main Feb 19, 2021
@notZaki notZaki deleted the subsample_ndims branch February 19, 2021 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants