From 0919e6dd55bb5d100c28290ccb09598b43dfb1e2 Mon Sep 17 00:00:00 2001 From: "Austin E. Soplata" Date: Tue, 26 Mar 2024 14:38:27 +0100 Subject: [PATCH] Make Alexis changes to CLI --- atlas_placement_hints/app/placement_hints.py | 40 ++++++-------------- atlas_placement_hints/layered_atlas.py | 7 ++-- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/atlas_placement_hints/app/placement_hints.py b/atlas_placement_hints/app/placement_hints.py index bd3fd2a..0d4af04 100644 --- a/atlas_placement_hints/app/placement_hints.py +++ b/atlas_placement_hints/app/placement_hints.py @@ -5,7 +5,6 @@ import json import logging import os -import sys from pathlib import Path from typing import List, Optional @@ -319,20 +318,10 @@ def isocortex( meshes. It will be created if it doesn't exist.""", ) @click.option( - "--create-uncut-thalamus-meshes-flag", - required=False, - help="""(Optional) Flag to create the initial thalamus meshes for manual - cutting later. This will not produce placement-hints. You MUST pass either - this flag or '--load-cut-thalamus-meshes-flag'.""", - default=False, - is_flag=True, -) -@click.option( - "--load-cut-thalamus-meshes-flag", + "--load-cut-thalamus-meshes", required=False, help="""(Optional) Flag to load your custom thalamus meshes, and then use - them to calculate placement-hints. You MUST pass either this flag or - '--create-uncut-thalamus-meshes-flag'.""", + them to calculate placement-hints.""", default=False, is_flag=True, ) @@ -346,13 +335,15 @@ def thalamus( direction_vectors_path, output_dir, thalamus_meshes_dir, - create_uncut_thalamus_meshes_flag, - load_cut_thalamus_meshes_flag, + load_cut_thalamus_meshes, ): """Generate and save the placement hints of the mouse thalamus. - Note that you MUST pass either '--create-uncut-thalamus-meshes-flag' or - '--load-cut-thalamus-meshes-flag'. + First, call this without passing '--load-cut-thalamus-meshes' to + create your region meshes, but not your placement-hints. Then, hand-cut + your meshes according to the documentation in + 'atlas_placement_hints/layered_atlas.py::ThalamusAtlas'. Finally, call + this again while passing '--load-cut-thalamus-meshes'. Placement hints are saved under the names specified in `app/metadata/thalamus_metadata.json`. These default to: @@ -380,17 +371,14 @@ def thalamus( For instructions on all steps necessary to generate the thalamus' placement hints, see - 'atlas-placement-hints/atlas_placement_hints/layered_atlas.py:ThalamusAtlas' + 'atlas-placement-hints/atlas_placement_hints/layered_atlas.py::ThalamusAtlas' and its methods for details. """ set_verbose(L, verbose) atlas = _create_layered_atlas(annotation_path, hierarchy_path, metadata_path) - if create_uncut_thalamus_meshes_flag: - Path(thalamus_meshes_dir).mkdir(parents=True, exist_ok=True) - atlas.create_uncut_thalamus_meshes(thalamus_meshes_dir) - elif load_cut_thalamus_meshes_flag: + if load_cut_thalamus_meshes: _placement_hints( atlas, direction_vectors_path, @@ -399,12 +387,8 @@ def thalamus( has_hemispheres=True, ) else: - print( - """\n--> ERROR: You MUST pass either - '--create-uncut-thalamus-meshes-flag' or - '--load-cut-thalamus-meshes-flag'. Exiting.\n""" - ) - sys.exit() + Path(thalamus_meshes_dir).mkdir(parents=True, exist_ok=True) + atlas.create_uncut_thalamus_meshes(thalamus_meshes_dir) @app.command() diff --git a/atlas_placement_hints/layered_atlas.py b/atlas_placement_hints/layered_atlas.py index 6af6db1..e4cc343 100644 --- a/atlas_placement_hints/layered_atlas.py +++ b/atlas_placement_hints/layered_atlas.py @@ -338,10 +338,9 @@ class ThalamusAtlas(MeshBasedLayeredAtlas): for the thalamus has been changed, and now requires a manual step. You should do the following steps: - 1. Pass both the argument '--thalamus-meshes-dir /your/folder/here' and the - flag '--create-uncut-thalamus-meshes' to the top-level CLI command - 'atlas-placement-hints thalamus'. This will create the meshes, but NOT the - placement-hints, and the program will exit. + 1. Pass the argument '--thalamus-meshes-dir /your/folder/here' to the + top-level CLI command 'atlas-placement-hints thalamus'. This will create + the meshes, but NOT the placement-hints, and the program will exit. 2. MANUALLY cut the reticular meshes into the 'top' and 'bottom' halves (aka the inner and outer halves if looking outwards from the center of the