Skip to content

Commit

Permalink
moved nnunet_urls to resource_urls
Browse files Browse the repository at this point in the history
TODO: use other urls too
  • Loading branch information
akhanf committed Feb 14, 2024
1 parent bf4ca6b commit e7ca2b2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
8 changes: 0 additions & 8 deletions hippunfold/config/nnunet_model_urls.yml

This file was deleted.

34 changes: 25 additions & 9 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,31 @@ modality: T2w


#these will be downloaded to ~/.cache/hippunfold
nnunet_model:
T1w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task101_hcp1200_T1w.nnUNetTrainerV2.model_best.tar'
T2w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task102_hcp1200_T2w.nnUNetTrainerV2.model_best.tar'
hippb500: 'zenodo.org/record/5732291/files/trained_model.3d_fullres.Task110_hcp1200_b1000crop.nnUNetTrainerV2.model_best.tar'
neonateT1w: 'zenodo.org/record/5733556/files/trained_model.3d_fullres.Task205_hcp1200_b1000_finetuneround2_dhcp_T1w.nnUNetTrainerV2.model_best.tar'
neonateT1w_v2: 'zenodo.org/record/8209029/files/trained_model.3d_fullres.Task301_dhcp_T1w_synthseg_manuallycorrected.nnUNetTrainer.model_best.tar'
T1T2w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task103_hcp1200_T1T2w.nnUNetTrainerV2.model_best.tar'
synthseg_v0.1: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task102_synsegGenDetailed.nnUNetTrainerV2.model_best.tar'
synthseg_v0.2: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task203_synthseg.nnUNetTrainerV2.model_best.tar'
resource_urls:
nnunet_model:
T1w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task101_hcp1200_T1w.nnUNetTrainerV2.model_best.tar'
T2w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task102_hcp1200_T2w.nnUNetTrainerV2.model_best.tar'
hippb500: 'zenodo.org/record/5732291/files/trained_model.3d_fullres.Task110_hcp1200_b1000crop.nnUNetTrainerV2.model_best.tar'
neonateT1w: 'zenodo.org/record/5733556/files/trained_model.3d_fullres.Task205_hcp1200_b1000_finetuneround2_dhcp_T1w.nnUNetTrainerV2.model_best.tar'
neonateT1w_v2: 'zenodo.org/record/8209029/files/trained_model.3d_fullres.Task301_dhcp_T1w_synthseg_manuallycorrected.nnUNetTrainer.model_best.tar'
T1T2w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task103_hcp1200_T1T2w.nnUNetTrainerV2.model_best.tar'
synthseg_v0.1: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task102_synsegGenDetailed.nnUNetTrainerV2.model_best.tar'
synthseg_v0.2: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task203_synthseg.nnUNetTrainerV2.model_best.tar'
atlas:
multihist7: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b782827451220b86dd8/?zip='
bigbrain: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8b13d27b123094c96f/?zip='
magdeburg: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8013d27b122f94c938/?zip='
freesurfer: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8513d27b123094c96a/?zip='
template:
CITI168: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395bf0282745121fb86a93/?zip='
dHCP: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395bff13d27b123094c9b4/?zip='
MBMv2: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395c0887852d133ca597dd/?zip='
MBMv3: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395c0e8a28b11240ffc6e9/?zip='
upenn: 'files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395c1613d27b122a94ca09/?zip='
#to get hash, see https://github.com/CenterForOpenScience/osf.io/issues/8256#issuecomment-379833911




crop_native_box: '256x256x256vox'
crop_native_res: '0.2x0.2x0.2mm'
Expand Down
10 changes: 10 additions & 0 deletions hippunfold/workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,16 @@ def get_work_dir(wildcards):
return folder_without_file


def get_download_dir():
if "HIPPUNFOLD_CACHE_DIR" in os.environ.keys():
download_dir = os.environ["HIPPUNFOLD_CACHE_DIR"]
else:
# create local download dir if it doesn't exist
dirs = AppDirs("hippunfold", "khanlab")
download_dir = dirs.user_cache_dir
return download_dir


rule archive_work_after_final:
input:
get_final_subj_output(),
Expand Down
13 changes: 4 additions & 9 deletions hippunfold/workflow/rules/nnunet.smk
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,14 @@ def get_nnunet_input(wildcards):

def get_model_tar():

if "HIPPUNFOLD_CACHE_DIR" in os.environ.keys():
download_dir = os.environ["HIPPUNFOLD_CACHE_DIR"]
else:
# create local download dir if it doesn't exist
dirs = AppDirs("hippunfold", "khanlab")
download_dir = dirs.user_cache_dir
download_dir=get_download_dir()

if config["force_nnunet_model"]:
model_name = config["force_nnunet_model"]
else:
model_name = config["modality"]

local_tar = config["nnunet_model"].get(model_name, None)
local_tar = config["resource_urls"]["nnunet_model"].get(model_name, None)
if local_tar == None:
print(f"ERROR: {model_name} does not exist in nnunet_model in the config file")

Expand Down Expand Up @@ -91,9 +86,9 @@ def parse_trainer_from_tar(wildcards, input):

rule download_model:
params:
url=config["nnunet_model"][config["force_nnunet_model"]]
url=config["resource_urls"]["nnunet_model"][config["force_nnunet_model"]]
if config["force_nnunet_model"]
else config["nnunet_model"][config["modality"]],
else config["resource_urls"]["nnunet_model"][config["modality"]],
output:
model_tar=get_model_tar(),
container:
Expand Down

0 comments on commit e7ca2b2

Please sign in to comment.