Switch to unified view

a b/docs/usage/specializedScans.md
1
# Specialized scans
2
3
This tutorial will cover how HippUnfold can be applied to non-standard
4
data including ex-vivo scans, super-high resolution data (eg. \<0.3mm
5
isotropic), non-MRI 3D imaging data, or scans where a corresponding
6
whole-brain T1w image is not available.
7
8
We will show how the available flags can be adapted for these use-cases
9
with several worked examples.
10
11
## Case 1: super high resolution
12
13
In this example, we have only a limited field of view covering the
14
hippocampus, and the resolution and contrast do not closely match the
15
training data of HippUnfold (0.3-1.0mm isotropic T1w, T2w, or DWI data).
16
This could be ex-vivo MRI data, or it could even be 3D microscopy data
17
as in our recent [3D BigBrain
18
publication](https://www.sciencedirect.com/science/article/pii/S105381191930919X).
19
Thus we don\'t expect HippUnfold\'s inbuilt UNet to be successful in
20
segmenting hippocampal tissue before unfolding, and we do not want to
21
downsample our data to accommodate HippUnfold\'s usual UNet and
22
unfolding workflow in `space-corobl` (which consists of 0.3mm isotropic
23
resampling cropped coronally-oblique to the hippocampus).
24
25
This will require manual segmentation of hippocampal grey matter, SRLM,
26
and neighbouring structures, though in the future we hope to include
27
models trained with higher resolution data (and contrasts more common in
28
ex-vivo scanning). This should be done according to the protocol
29
outlined
30
[here](https://ars.els-cdn.com/content/image/1-s2.0-S1053811917309977-mmc1.pdf)
31
or, more recently, the video example
32
[here](https://www.youtube.com/watch?v=mUQJ2GUcnLU&t=1s). This manual
33
segmentation file should have the `_dseg` suffix.
34
35
Here is an example of what the input directory might look like:
36
37
    exvivo/
38
    └── sub-001/
39
        ├── sub-001_hemi-R_desc-hippo_T2w.nii.gz
40
        └── sub-001_hemi-R_desc-hippo_dseg.nii.gz
41
42
This can be unfolded with the command:
43
44
    hippunfold . PATH_TO_OUTPUT_DIR participant --modality cropseg \
45
    --path_cropseg exvivo/sub-{subject}/sub-{subject}_hemi-{hemi}_desc-hippo_dseg.nii.gz \
46
    --hemi R --skip_inject_template_labels
47
48
Explanation: `--modality cropseg` informs HippUnfold that the input
49
manual segmentation should not be resampled and UNet does not need to be
50
run. Because of a limitation in bids parsing for the `hemi`
51
entity, we need to use the generic path input,
52
`--path_cropseg` in this case, making sure we use the
53
`{subject}` and `{hemi}` wildcards in the
54
filename. Output files will be named with `space-corobl` because
55
HippUnfold is coded to effectively treat all files as already being in
56
this space. We need the `--hemi R` to prevent HippUnfold looking for
57
both hemispheres. Finally, because this segmentation was performed
58
manually on very high resolution data, we can optionally consider
59
skipping the template shape injection step with
60
`--skip_inject_template_labels`. Template shape injection can fix minor
61
errors in segmentation from UNet or from an imperfect manual rater, at
62
the cost of smoothing out some details of the hippocampus due to the
63
fact that it uses deformable registration with inherent smoothness
64
contraints.
65
66
Note that because we are not resampling to the CITI168 template or using
67
UNet, the T2w image in this example is effectively not being used at
68
all. Instead, the provided manual segmentation makes up the basis for
69
unfolding.
70
71
## Case 2: one ex-vivo hemisphere 
72
In this example, we have a single hemisphere that was scanned ex-vivo at a
73
nearly standard resolution and T2w contrast. Because the resolution and
74
contrast are similar to the HippUnfold training data, we expect UNet
75
will work and so we don\'t need to perform manual segemntation. However,
76
due to gross deformations and the missing hemisphere, we don\'t expect
77
this sample to register well to the standard CITI168 template. Thus, we
78
will need to manually resample the image to the CITI168 template prior
79
to running HippUnfold, focusing in particular on aligning the
80
hippocampus. Once done, we may have a directory like this:
81
82
    PATH_TO_EXVIVO_DIR/
83
    └── sub-001/
84
        ├── sub-001_hemi-R_desc-exvivo_T2w.nii.gz
85
        ├── sub-001_hemi-R_affine-exvivo-to-CITI168_xfm.txt
86
        └── sub-001_hemi-R_desc-exvivo_space-CITI168_T2w.nii.gz
87
88
Note that only the last file is needed for unfolding:
89
90
    hippunfold . PATH_TO_OUTPUT_DIR participant --output_spaces corobl --hemi R --no_reg_template \
91
    --path_T2w PATH_TO_EXVIVO_DIR/sub-001/sub-001_hemi-R_desc-exvivo_space-CITI168_T2w.nii.gz \
92
    --output_spaces corobl
93
94
Here we need to use `--path_T2w` to specify which input should be used,
95
and `--no_reg_template` to specify that it is already in
96
`space-CITI168`. In this case, we also specified
97
`--output_spaces corobl`. This is not needed, but is useful when we are
98
interested in only the hippocampus as `space-corobl` is higher
99
resolution and cropped more nicely around the hippocampus then the
100
original scan, making it a good space to perform subsequent analyses.
101
Alternatively, outputs can be transformed back to the original space
102
using the inverted transform
103
`sub-001_hemi-R_affine-exvivo-to-CITI168_xfm.txt`.
104
105
This same usage could also be applied in a standard MRI case where no
106
T1w image is available.