From 5dea74521422e5f79eee333a7aa3288a60e2876f Mon Sep 17 00:00:00 2001 From: Nick Tustison Date: Sun, 23 Aug 2026 08:26:33 -0700 Subject: [PATCH 1/2] ENH: Use new deep atropos. --- antspynet/utilities/white_matter_hyperintensity_segmentation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antspynet/utilities/white_matter_hyperintensity_segmentation.py b/antspynet/utilities/white_matter_hyperintensity_segmentation.py index 3620f99..13bd663 100644 --- a/antspynet/utilities/white_matter_hyperintensity_segmentation.py +++ b/antspynet/utilities/white_matter_hyperintensity_segmentation.py @@ -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 From fa868121e5b2f8afac643a37b9524d57a43ede8f Mon Sep 17 00:00:00 2001 From: Nick Tustison Date: Wed, 7 Oct 2026 07:47:05 -0700 Subject: [PATCH 2/2] ENH: PET brain extraction. --- antspynet/utilities/brain_extraction.py | 27 ++++++++++++++++--- antspynet/utilities/get_pretrained_network.py | 2 ++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/antspynet/utilities/brain_extraction.py b/antspynet/utilities/brain_extraction.py index 5cde789..af95e13 100644 --- a/antspynet/utilities/brain_extraction.py +++ b/antspynet/utilities/brain_extraction.py @@ -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. @@ -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": @@ -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.") @@ -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) diff --git a/antspynet/utilities/get_pretrained_network.py b/antspynet/utilities/get_pretrained_network.py index c96eb1a..89f4d77 100644 --- a/antspynet/utilities/get_pretrained_network.py +++ b/antspynet/utilities/get_pretrained_network.py @@ -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", @@ -216,6 +217,7 @@ def switch_networks(argument): "brainExtractionRobustBOLD", "brainExtractionFA", "brainExtractionMra", + "brainExtractionPet", "brainExtractionRobustFA", "brainExtractionNoBrainer", "brainExtractionInfantT1T2",