Skip to content

Commit

Permalink
Save all seeds into common /assets/seeds/ rather than dataset specifi…
Browse files Browse the repository at this point in the history
…c folders
  • Loading branch information
VemundFredriksen committed Oct 29, 2023
1 parent 1ac1b94 commit 82f459c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions synthlung/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from lungmask import LMInferer
import json

def seed_msd():
json_file_path = "./assets/source/msd/dataset.json"
def seed():
json_file_path = "./assets/source/dataset.json"

with open(json_file_path, 'r') as json_file:
image_dict = json.load(json_file)
crop_pipeline = TumorCropPipeline()
crop_pipeline(image_dict)
formatter = MSDGenerateJSONFormatter("./assets/seeds/msd/")
formatter = MSDGenerateJSONFormatter("./assets/seeds/")
formatter.generate_json()

def format_msd():
Expand Down Expand Up @@ -55,8 +55,7 @@ def main():
if(args.dataset == "msd"):
format_msd()
elif args.action == "seed":
if(args.dataset == "msd"):
seed_msd()
seed()
elif args.action == "generate":
if(args.dataset == "msd"):
generate_randomized_tumors()
Expand Down
2 changes: 1 addition & 1 deletion synthlung/utils/dataset_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LABEL_NII_GZ = 'label.nii.gz'

class MSDImageSourceFormatter(ImageSourceFormatter, JSONGenerator):
def __init__(self, source_directory: str = "./assets/Task06_Lung/", target_directory: str = "./assets/source/msd/") -> None:
def __init__(self, source_directory: str = "./assets/Task06_Lung/", target_directory: str = "./assets/source/") -> None:
self.target_directory = target_directory
self.source_directory = source_directory

Expand Down
4 changes: 2 additions & 2 deletions synthlung/utils/tumor_isolation_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def __init__(self) -> None:
LoadImaged(keys=['image', 'label'], image_only = False),
TumorSeedIsolationd(image_key='image', label_key='label', image_output_key='seed_image', label_output_key='seed_label'),
RenameSourceToSeed(meta_dict_keys=['seed_image_meta_dict', 'seed_label_meta_dict']),
SaveImaged(keys=['seed_image'], output_dir='./assets/seeds/msd/', output_postfix='', separate_folder=False),
SaveImaged(keys=['seed_label'], output_dir='./assets/seeds/msd/', output_postfix='', separate_folder=False)
SaveImaged(keys=['seed_image'], output_dir='./assets/seeds/', output_postfix='', separate_folder=False),
SaveImaged(keys=['seed_label'], output_dir='./assets/seeds/', output_postfix='', separate_folder=False)
])

def __call__(self, image_dict) -> None:
Expand Down

0 comments on commit 82f459c

Please sign in to comment.