Skip to content

Commit

Permalink
use brainglobe atlas names directly
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltyson committed Jul 14, 2020
1 parent 29d0c02 commit a24f534
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
43 changes: 4 additions & 39 deletions brainreg/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@
temp_dir = tempfile.TemporaryDirectory()
temp_dir_path = temp_dir.name

valid_atlases = {
"allen_25": "allen_mouse_25um",
"allen_50": "allen_mouse_50um",
"kim_25": "kim_unified_25um",
"kim_50": "kim_unified_50um",
"rat": "ratatlas",
"zebrafish": "mpin_zfish_1um",
"human": "allen_human_500um",
}


def register_cli_parser():
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
Expand Down Expand Up @@ -82,8 +72,9 @@ def atlas_parse(parser):
"--atlas",
dest="atlas",
type=str,
default="allen_25",
help="Atlas to use for registration",
default="allen_mouse_25um",
help="Brainglobe atlas to use for registration. Run 'brainglobe list' "
"to see the atlases available.",
)
return parser

Expand Down Expand Up @@ -187,31 +178,10 @@ def prep_registration(args):
return args, additional_images_downsample


def valid_atlas(atlas_name):
"""
Ensures a correct atlas is chosen
:param atlas_name: Input value
:param atlases: Dict of allowed atlases
"""

if atlas_name not in valid_atlases.keys():
raise ArgumentTypeError(
f"Atlas: {atlas_name} is not valid. Please "
f"choose one of: {list(valid_atlases.keys())}"
)


class Atlas(BrainGlobeAtlas):
def __init__(self, atlas_name, valid_atlases, *args, **kwargs):
self.atlas_name = valid_atlases[atlas_name]
BrainGlobeAtlas.__init__(self, *args, **kwargs)


def run():
start_time = datetime.now()
args = register_cli_parser().parse_args()
arg_groups = get_arg_groups(args, register_cli_parser())
valid_atlas(args.atlas)
args = define_pixel_sizes(args)

args, additional_images_downsample = prep_registration(args)
Expand All @@ -227,15 +197,10 @@ def run():

logging.info("Starting registration")

# atlas = Atlas(args.atlas, valid_atlases)
atlas = BrainGlobeAtlas(valid_atlases[args.atlas])
# TODO: get this from atlas metadata
atlas_orientation = "asl"
# atlas_orientation = atlas.metadata["orientation"]
atlas = BrainGlobeAtlas(args.atlas)

register(
atlas,
atlas_orientation,
args.orientation,
args.image_paths,
args.brainreg_directory,
Expand Down
5 changes: 2 additions & 3 deletions brainreg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def make_hemispheres_stack(shape):

def main(
atlas,
atlas_orientation,
data_orientation,
target_brain_path,
registration_output_folder,
Expand Down Expand Up @@ -102,7 +101,7 @@ def main(
)

target_brain = bg.map_stack_to(
data_orientation, atlas_orientation, target_brain
data_orientation, atlas.metadata["orientation"], target_brain
)

# TODO: incororate this into bg-atlasapi
Expand All @@ -118,7 +117,7 @@ def main(
n_processes,
additional_images_downsample,
data_orientation,
atlas_orientation,
atlas.metadata["orientation"],
niftyreg_args,
target_brain_path,
x_scaling,
Expand Down

0 comments on commit a24f534

Please sign in to comment.