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

[WIP] ENH: Load/save linear transform array (LTA) files #565

Closed
wants to merge 1 commit into from

Conversation

effigies
Copy link
Member

This is a first pass at supporting loading and saving of LTA files. This is a pretty flexible structure that encodes the geometry (equivalent to the VOX-RAS affine) of the source and target spaces, and an affine transform between those spaces.

I'm using LabeledWrapStruct essentially as a way to enforce numpy typing on a dict. The VolumeGeometry type seems like it may recur a bit in FreeSurfer, as it shows up in geometry files, as well.

The end goal is to support conversion between different affine formats. Because I'm working with the three formats regularly, I'll aim for LTA (.lta), FSL (.mat) and ITK (.txt) formats first.

A not-incidental secondary goal will be to document these different formats, as most of their existing documentation is the parsing/emitting code in the various packages that support these formats.

TODO:

  • Support conversion between LTA types (VOX_TO_VOX and RAS_TO_RAS, at minimum)
  • Support concatenation of LTA transforms

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 95.882% when pulling b8844ec on effigies:enh/linear_transform_array into b7eee37 on nipy:master.

@effigies effigies force-pushed the enh/linear_transform_array branch from b8844ec to 7a3f71a Compare November 23, 2017 14:07
@codecov-io
Copy link

codecov-io commented Nov 23, 2017

Codecov Report

Merging #565 into master will decrease coverage by 0.70%.
The diff coverage is 26.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #565      +/-   ##
==========================================
- Coverage   91.85%   91.15%   -0.71%     
==========================================
  Files          97       98       +1     
  Lines       12357    12490     +133     
  Branches     2177     2190      +13     
==========================================
+ Hits        11351    11385      +34     
- Misses        675      774      +99     
  Partials      331      331              
Impacted Files Coverage Δ
nibabel/freesurfer/lta.py 25.56% <25.56%> (ø)
nibabel/wrapstruct.py 97.01% <100.00%> (ø)

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 2f86a4a...d5f4a08. Read the comment docs.

@matthew-brett
Copy link
Member

Chris - this may not be relevant - but there's some stuff on the FSL mat format here : https://github.com/nipy/dipy/blob/master/dipy/external/fsl.py#L69

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 95.875% when pulling 7a3f71a on effigies:enh/linear_transform_array into 2817d1b on nipy:master.

@matthew-brett
Copy link
Member

Chris - where are we with this one?

@effigies
Copy link
Member Author

effigies commented Mar 9, 2018

The status here is that it's stalled. Now I have a better understanding of the different affine conventions (i.e. FSL using a voxel-based origin, ITK ignoring sforms) the urgency of working through all of this has fallen away a little bit.

I'd be up for trying to make a roadmap for handling affine transforms, but I think that's going to involve settling on a common internal representation. I actually like the LTA approach, which includes both the source and target spaces, which means that this information is sufficient to produce an FSL or ITK matrix.

But #567 is my highest priority when I have time, followed by #550.

@oesteban
Copy link
Contributor

@effigies do you want to move this one to poldracklab/nitransforms until that is finished and we pull everything together in nibabel's proper?

mgxd added a commit to mgxd/nitransforms that referenced this pull request Oct 18, 2019
mgxd added a commit to mgxd/nitransforms that referenced this pull request Oct 18, 2019
@effigies effigies force-pushed the enh/linear_transform_array branch from dacf547 to d5f4a08 Compare May 27, 2020 21:47
@pep8speaks
Copy link

Hello @effigies, Thank you for updating!

Line 82:9: E722 do not use bare 'except'

To test for issues locally, pip install flake8 and then run flake8 nibabel.

@effigies
Copy link
Member Author

This should be superseded by nitransforms.

@effigies effigies closed this Feb 19, 2022
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.

6 participants