Skip to content

Commit

Permalink
added bids related args
Browse files Browse the repository at this point in the history
  • Loading branch information
Reza committed May 15, 2024
1 parent 414b195 commit a1ec65f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
18 changes: 13 additions & 5 deletions pyalfe/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dependency_injector import containers, providers

from pyalfe.data_structure import DefaultALFEDataDir, Modality
from pyalfe.data_structure import DefaultALFEDataDir, BIDSDataDir, Modality
from pyalfe.image_processing import Convert3DProcessor, NilearnProcessor
from pyalfe.image_registration import GreedyRegistration, AntsRegistration
from pyalfe.inference import NNUnetV2
Expand Down Expand Up @@ -34,10 +34,18 @@ class Container(containers.DeclarativeContainer):
logger = logging.getLogger('Container')
config = providers.Configuration()

pipeline_dir = providers.Singleton(
DefaultALFEDataDir,
output_dir=config.options.output_dir,
input_dir=config.options.input_dir,
pipeline_dir = providers.Selector(
config.options.data_dir_structure,
alfe=providers.Singleton(
DefaultALFEDataDir,
output_dir=config.options.output_dir,
input_dir=config.options.input_dir,
),
bids=providers.Singleton(
BIDSDataDir,
output_dir=config.options.output_dir,
input_dir=config.options.input_dir,
),
)

image_processor = providers.Selector(
Expand Down
15 changes: 13 additions & 2 deletions pyalfe/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def run(
dominant_tissue: str,
image_processor: str,
image_registration: str,
data_dir_structure: str,
overwrite: bool,
) -> None:
"""Runs the pipeline for an accession number.
Expand All @@ -116,10 +117,12 @@ def run(
comma separated target modalities
dominant_tissue : str, default='white_matter'
dominant tissue
image_processor : str, default=c3d
image_processor : str, default='c3d'
image processor that is used by the pipeline.
image_registration : str, default=greedy
image_registration : str, default='greedy'
image registration that is used by the pipeline.
data_dir_structure: str, default='alfe'
the data directory structure, it can be 'alfe' or 'bids'.
overwrite : bool
if True, the pipeline overwrites existing output images.
Expand All @@ -146,6 +149,8 @@ def run(
options['image_processor'] = image_processor
if image_registration:
options['image_registration'] = image_registration
if data_dir_structure:
options['data_dir_structure'] = data_dir_structure
options['overwrite_images'] = overwrite

container.config.from_dict(options)
Expand Down Expand Up @@ -197,6 +202,11 @@ def configure():
type=click.Choice(['greedy', 'ants']),
default='greedy',
)
data_dir_structure = click.prompt(
'data directory structure (press enter for default)',
type=click.Choice(['alfe', 'bids']),
default='alfe',
)
config_path = click.prompt('config path', default=DEFAULT_CFG)
config = configparser.ConfigParser()
config['options'] = {
Expand All @@ -207,6 +217,7 @@ def configure():
'dominant_tissue': dominant_tissue,
'image_processor': image_processor,
'image_registration': image_registration,
'data_dir_structure': data_dir_structure,
}

config_parent_path = os.path.dirname(config_path)
Expand Down

0 comments on commit a1ec65f

Please sign in to comment.