-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added info for how to fix sMRI files.
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Fix sform code of structurals. | ||
This script uses FSL to set the sform code of any structural | ||
whose sform code is not 1 or 4 to make sure it is compatible | ||
with OSL. | ||
Warning: this script will permanently change the SMRI file. | ||
""" | ||
|
||
import nibabel as nib | ||
|
||
from osl import source_recon | ||
|
||
source_recon.setup_fsl("/path/to/fsl") | ||
|
||
# Paths to files to fix | ||
files = [ | ||
"smri/sub-001.nii.gz", | ||
"smri/sub-002.nii.gz", | ||
] | ||
|
||
for file in files: | ||
smri = nib.load(file) | ||
sformcode = smri.header.get_sform(coded=True)[-1] | ||
if sformcode not in [1, 4]: | ||
cmd = f"fslorient -setsformcode 1 {file}" | ||
source_recon.rhino.utils.system_call(cmd) | ||
|
||
print("Done”) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters