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

ENH: Add MZ3 format #1066

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

ENH: Add MZ3 format #1066

wants to merge 3 commits into from

Conversation

effigies
Copy link
Member

Currently implements reading the header and "scalar" array. Haven't tested if we need to switch ordering to handle multiple scalar arrays. Does not yet implement reading vertices, faces or rgba.

Two significant wrinkles to this format:

  1. Gzipped and uncompressed versions have the same extension.
  2. The data array size must be calculated from the file size. For the compressed case, I first try to use the member-size mod 2**32 field in the gzip footer to detect the size. If we hit 20GB we bet that it's a weird file and just seek to the end of the gzip stream.

Loading face/header data will be a good test for BIAP 0009 (#1056), but don't want to clog up that PR at the moment.

@pep8speaks
Copy link

pep8speaks commented Nov 19, 2021

Hello @effigies, Thank you for updating!

Line 175:1: W293 blank line contains whitespace

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

Comment last updated at 2021-11-19 13:45:48 UTC

@codecov
Copy link

codecov bot commented Nov 19, 2021

Codecov Report

Merging #1066 (fdd94d1) into master (4703f4d) will decrease coverage by 0.77%.
The diff coverage is 28.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1066      +/-   ##
==========================================
- Coverage   92.30%   91.53%   -0.78%     
==========================================
  Files         100      101       +1     
  Lines       12223    12363     +140     
  Branches     2194     2221      +27     
==========================================
+ Hits        11282    11316      +34     
- Misses        617      721     +104     
- Partials      324      326       +2     
Impacted Files Coverage Δ
nibabel/surfice.py 25.92% <25.92%> (ø)
nibabel/openers.py 92.56% <42.85%> (-3.17%) ⬇️
nibabel/arrayproxy.py 100.00% <100.00%> (ø)
nibabel/streamlines/array_sequence.py 97.95% <0.00%> (-0.69%) ⬇️

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 4703f4d...fdd94d1. Read the comment docs.

@neurolabusc
Copy link

@effigies thanks for supporting this. The mz3 specification is here.

  • It is true that a single extension is used for both compressed and uncompressed data. You can discriminate these by looking at the first two bytes of the file. Specifically, all GZip files begin with hex = 0x1F8B, all uncompressed MZ3 files begin with hex = 0x4D5A
  • You do not need to know the file size to compute the array size. The header NFACE and NVERT explicitly describe the number of indexed triangles (faces) and spatial points (vertices).

Happy to work directly with you to tidy this up.

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.

None yet

3 participants