ContextLab / ContextLab/supereeg

refactor loading/saving of nifti files

Open
#43 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
38
Forks
19
PR merge metrics
No merged PRs in 30d

Description

_I'm imagining that BrainObject.nii is a function that takes either 0 or 1 argument. If 0 arguments are passed in, it returns itself as a nifti object. If 1 argument is passed in, it treats that argument as a template (which can be specified as a BrainObject object or a NiftiImage object). In other words, this should work similarly to a numpy array where x.T returns the transpose of x.

To facilitate easy translating between brain data in different formats, I'd make a read_brain function that takes in data (in whatever format) and returns a brain object. So:

If you pass in a brain object, the read_brain function returns its argument
If you pass in a string that links to a brain object, you load that brain object into memory and return it
If you pass in a nifti object, you convert it to a brain object and return it
If you pass in a string that links to a .nii or .nii.gz file, you load it into memory, convert it to a brain object, and return it.
Anytime you need to parse brain data, you can then call the read_brain function to get out the data in brain object format.

Similarly, you can create a write_brain function that takes in brain data (in whatever format) and a string (with a .bo, .nii., or .nii.gz extension). First you can call read_brain to convert whatever you've been given into a brain object, and then you'd either write that brain object to disk (if you're given the .bo extension) or convert it to nifti format and write to disk (if you're given the .nii or .nii.gz extension)._ (moved from #27)

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the existing BrainObject and NiftiImage interfaces and current parsing paths first. Compare the requested read_brain and write_brain conversions and BrainObject.nii template behavior against those paths; done means the listed input and output forms work consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.