-
Notifications
You must be signed in to change notification settings - Fork 197
tckglobal: don't invoke get_image() with invalid Header! #3171
Copy link
Copy link
Description
Describe the bug
I get this bug when I run tckglobal. I am on a mac and have tried using both the HCP and HBN datasets.
tckglobal: [INFO] Initialise data structures for global tractography.
tckglobal: [DEBUG] memory-mapping file "/var/folders/rg/wqvgdwpd2jb1b0vpszd5z2w40000gn/T/tmp6_mt2klw/dwi.mif"...
tckglobal: [DEBUG] file "/var/folders/rg/wqvgdwpd2jb1b0vpszd5z2w40000gn/T/tmp6_mt2klw/dwi.mif" mapped at 0x101970000, size 783591408 (read-only)
tckglobal: [DEBUG] image "/var/folders/rg/wqvgdwpd2jb1b0vpszd5z2w40000gn/T/tmp6_mt2klw/dwi.mif" loaded
tckglobal: [DEBUG] image "/var/folders/rg/wqvgdwpd2jb1b0vpszd5z2w40000gn/T/tmp6_mt2klw/dwi.mif" initialised with strides = [ -1 -108 13932 1518588 ], start = 13931, using direct IO
tckglobal: [DEBUG] initialising threads...
tckglobal: [DEBUG] launching 8 threads "loop threads"...
tckglobal: [DEBUG] waiting for completion of threads "loop threads"...
tckglobal: [DEBUG] threads "loop threads" completed OK
tckglobal: [DEBUG] image "/var/folders/rg/wqvgdwpd2jb1b0vpszd5z2w40000gn/T/tmp6_mt2klw/dwi.mif" initialised with strides = [ -129 -13932 1797228 1 ], start = 1797099, using direct IO
tckglobal: [DEBUG] Initialise particle grid.
tckglobal: [DEBUG] unmapping file "/var/folders/rg/wqvgdwpd2jb1b0vpszd5z2w40000gn/T/tmp6_mt2klw/dwi.mif"
tckglobal: [DEBUG] image "/var/folders/rg/wqvgdwpd2jb1b0vpszd5z2w40000gn/T/tmp6_mt2klw/dwi.mif" unloaded
tckglobal: [100%] running MH sampler
tckglobal: [ERROR] FIXME: don't invoke get_image() with invalid Header!
To Reproduce
The bug can be fully reproduced with this script. It downloads an HBN subject. It is a little more simplified than my initial runs, where I am doing 5tt, but it triggers the same error and is shorter:
import os
import subprocess
import tempfile
import nibabel as nib
import numpy as np
from dipy.core.gradients import gradient_table
from dipy.data import fetch_hbn
_, hbn_path = fetch_hbn(subjects=["NDARAV554TP2"])
fname = f"{hbn_path}/derivatives/qsiprep/sub-NDARAV554TP2/ses-HBNsiteRU/dwi/sub-NDARAV554TP2_ses-HBNsiteRU_acq-64dir_space-T1w_desc-preproc_dwi.nii.gz"
fbval = f"{hbn_path}/derivatives/qsiprep/sub-NDARAV554TP2/ses-HBNsiteRU/dwi/sub-NDARAV554TP2_ses-HBNsiteRU_acq-64dir_space-T1w_desc-preproc_dwi.bval"
fbvec = f"{hbn_path}/derivatives/qsiprep/sub-NDARAV554TP2/ses-HBNsiteRU/dwi/sub-NDARAV554TP2_ses-HBNsiteRU_acq-64dir_space-T1w_desc-preproc_dwi.bvec"
img = nib.load(fname)
gtab = gradient_table(fbval, fbvec)
data = img.get_fdata(dtype=np.float32)
affine = img.affine
tmp_dir = tempfile.mkdtemp()
dwi_file = os.path.join(tmp_dir, "dwi.nii.gz")
dwi_mif = os.path.join(tmp_dir, "dwi.mif")
nib.save(nib.Nifti1Image(data, affine), dwi_file)
subprocess.run([
"mrconvert", dwi_file, dwi_mif,
"-fslgrad", fbvec, fbval], check=True)
wm_response = os.path.join(tmp_dir, "wm_response.txt")
gm_response = os.path.join(tmp_dir, "gm_response.txt")
csf_response = os.path.join(tmp_dir, "csf_response.txt")
subprocess.run([
"dwi2response", "dhollander", dwi_mif,
wm_response, gm_response, csf_response])
global_file = os.path.join(tmp_dir, "tracks.tck")
fod_file = os.path.join(tmp_dir, "fod.mif")
cmd = [
"tckglobal",
dwi_mif,
wm_response,
"-riso", csf_response,
"-riso", gm_response,
"-niter", str(int(1e9)),
"-fod", fod_file,
"-debug",
global_file,
]
subprocess.run(
cmd, check=True)
Platform/Environment/Version
macOS 15.5
== mrinfo 3.0.7 ==
64 bit release version, built Jul 26 2025, using Eigen 3.4.0
Best,
John
Reactions are currently unavailable