There are two related ways to do this.
First, if you only want to identify fibers that pass through the
lesion mask, you can use the lesion NIfTI as an ROI and filter the
tract file:
dsi_studio --action=ana \
--source=subject.fib.gz \
--tract=bundle.trk.gz \
--roi=wm_lesion.nii.gz \
--output=bundle_overlap_lesion.tt.gz
This will save the portion of the tract file that overlaps/passes
through the lesion ROI. DSI Studio’s ana command supports existing
tract files, ROI filtering, and .trk.gz/.tt.gz tract input. (DSI
Studio Documentation)
If you have multiple lesion masks or an integer-labeled lesion map,
you can also compute a tract-to-region matrix:
dsi_studio --action=ana \
--source=subject.fib.gz \
--tract=bundle1.trk.gz,bundle2.trk.gz,bundle3.trk.gz \
--connectivity=lesion_labels.nii.gz
By default, the connectivity uses pass, meaning it counts tracts
passing through each region; --connectivity_type=end is only for
endpoint-based connectivity. (DSI Studio Documentation)
For a Dice coefficient, DSI Studio does not directly output a Dice
matrix. The practical way is to convert each tract bundle into a
binary NIfTI mask, then compute Dice between each tract mask and each
lesion mask:
dsi_studio --action=ana \
--source=subject.fib.gz \
--tract=bundle1.trk.gz \
--output=bundle1_mask.nii.gz \
--ref=wm_lesion.nii.gz
Then compute:
import nibabel as nib, numpy as np, pandas as pd, glob, os
tracts = sorted(glob.glob("tract_masks/*.nii.gz"))
lesions = sorted(glob.glob("lesions/*.nii.gz"))
def load_mask(f):
return nib.load(f).get_fdata() > 0
out = []
for t in tracts:
T = load_mask(t)
row = []
for l in lesions:
L = load_mask(l)
d = 2*np.logical_and(T,L).sum()/(T.sum()+L.sum())
row.append(d)
out.append(row)
pd.DataFrame(out,
index=[os.path.basename(f) for f in tracts],
columns=[os.path.basename(f) for f in lesions]
).to_csv("tract_lesion_dice.csv")
The Dice similarity coefficient is defined as 2 × overlap / (volume A
+ volume B). (PMC)
A key point is that the tract file, lesion mask, and FIB file must be
in the same space. If the lesion is in MNI space, DSI Studio can apply
MNI-to-native transformation when the ROI filename contains .mni.;
otherwise I would recommend first resampling the lesion mask to the
diffusion/FIB space. (DSI Studio Documentation)
Best,
Frank
> --
> You received this message because you are subscribed to the Google Groups "DSI Studio" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
dsi-studio+...@googlegroups.com.
> To view this discussion visit
https://groups.google.com/d/msgid/dsi-studio/2d331048-dd2d-4aed-bc56-c41a1b6fefb6n%40googlegroups.com.