Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions antspynet/utilities/brain_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def brain_extraction(image,
* "t2star": T2Star MRI.
* "bold": 3-D mean BOLD MRI. Previous versions are specified as "bold.v0".
* "fa": fractional anisotropy. Previous versions are specified as "fa.v0".
* "mra": MRA h/t Tyler Hanson "mmbop".
* "mra": MRA h/t Tyler H. "mmbop".
* "pet": PET (from DLBS dataset: OpenNeuro ds004856).
* "t1t2infant": Combined T1-w/T2-w infant MRI h/t Martin Styner.
* "t1infant": T1-w infant MRI h/t Martin Styner.
* "t2infant": T2-w infant MRI h/t Martin Styner.
Expand Down Expand Up @@ -145,6 +146,9 @@ def brain_extraction(image,
elif modality == "mra":
weights_file_name_prefix = "brainExtractionMra"
is_standard_network = True
elif modality == "pet":
weights_file_name_prefix = "brainExtractionPet"
is_standard_network = True
elif modality == "t1t2infant":
weights_file_name_prefix = "brainExtractionInfantT1T2"
elif modality == "t1infant":
Expand All @@ -166,7 +170,13 @@ def brain_extraction(image,
if verbose:
print("Brain extraction: retrieving model weights.")

weights_file_name = get_pretrained_network(weights_file_name_prefix)
if modality == "pet":
weights_file_name = get_pretrained_network(
weights_file_name_prefix,
target_file_name="brainExtractionPet.weights.h5",
)
else:
weights_file_name = get_pretrained_network(weights_file_name_prefix)

if verbose:
print("Brain extraction: retrieving template.")
Expand All @@ -184,8 +194,17 @@ def brain_extraction(image,
reorient_template = xfrm.apply_to_image(reorient_template)
else:
reorient_template = ants.image_read(get_antsxnet_data("S_template3"))
if is_standard_network and (modality != "t1.v1" and modality != "mra"):
ants.set_spacing(reorient_template, (1.5, 1.5, 1.5))
if modality == "pet":
reorient_template = ants.resample_image(
reorient_template,
resample_params=(1.5, 1.5, 1.5),
)
reorient_template = ants.pad_or_crop_image_to_size(
reorient_template, (136, 176, 176)
)
elif is_standard_network and modality not in ("t1.v1", "mra"):
ants.set_spacing(reorient_template, (1.5, 1.5, 1.5))

resampled_image_size = reorient_template.shape

number_of_filters = (8, 16, 32, 64)
Expand Down
2 changes: 2 additions & 0 deletions antspynet/utilities/get_pretrained_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def switch_networks(argument):
"brainExtractionRobustBOLD": "https://ndownloader.figshare.com/files/34870404",
"brainExtractionFA": "https://ndownloader.figshare.com/files/22761926",
"brainExtractionMra": "https://ndownloader.figshare.com/files/46335052",
"brainExtractionPet": "https://ndownloader.figshare.com/files/69729570",
"brainExtractionRobustFA": "https://ndownloader.figshare.com/files/34870410",
"brainExtractionNoBrainer": "https://ndownloader.figshare.com/files/22598039",
"brainExtractionInfantT1T2": "https://ndownloader.figshare.com/files/22968833",
Expand Down Expand Up @@ -216,6 +217,7 @@ def switch_networks(argument):
"brainExtractionRobustBOLD",
"brainExtractionFA",
"brainExtractionMra",
"brainExtractionPet",
"brainExtractionRobustFA",
"brainExtractionNoBrainer",
"brainExtractionInfantT1T2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def wmh_segmentation(flair,
if white_matter_mask is None:
if verbose:
print("Calculate white matter mask.")
atropos = deep_atropos(t1, do_preprocessing=True, verbose=verbose)
atropos = deep_atropos([t1, None, None], do_preprocessing=True, verbose=verbose)
white_matter_mask = ants.threshold_image(atropos['segmentation_image'], 3, 4, 1, 0)

t1_preprocessed = None
Expand Down
Loading