Skip to content

Commit

Permalink
Update with siibra v1.0a04
Browse files Browse the repository at this point in the history
Needs further testing and examples
  • Loading branch information
AhmetNSimsek committed Jan 8, 2024
1 parent 3b773cc commit eb87d07
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
siibra>=0.3a16
siibra>=1.0a04
click>=8.0
click_plugins>=1.0
simple-term-menu>=1.4
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def find_version():
""",
python_requires=">=3.7",
install_requires=[
"siibra>=0.3a16",
"siibra>=1.0a04",
"click>=8.0",
"click-plugins>=1.0",
"simple-term-menu>=1.4",
Expand Down
2 changes: 1 addition & 1 deletion siibra_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.2a2"
__version__ = "1.0a1"
25 changes: 13 additions & 12 deletions siibra_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,28 @@

# ---- Autocompletion


class SpaceName(click.ParamType):
name = "space"

def shell_complete(self, ctx, param, incomplete):
print(incomplete)
return [
click.CompletionItem(s.key)
for s in siibra.spaces
for s in siibra.spaces
if s.key.startswith(incomplete)
]
]


class ParcellationName(click.ParamType):
name = "parcellation"

def shell_complete(self, ctx, param, incomplete):
return [
click.CompletionItem(s.key)
for s in siibra.parcellations
for s in siibra.parcellations
if s.key.startswith(incomplete)
]
]


# ---- Main command
Expand Down Expand Up @@ -87,7 +91,6 @@ def get(ctx, outfile):
@click.pass_context
def map(ctx, parcellation, space):
"""Retrieve a parcellation map in the given space"""

import siibra as siibra

atlas = siibra.atlases[ctx.obj["species"]]
Expand Down Expand Up @@ -186,11 +189,11 @@ def find(ctx):
default=None,
)
@click.option(
"--tree/--no-tree",
"--showtree/--no-tree",
default=False,
)
@click.pass_context
def region(ctx, region, parcellation, tree):
def region(ctx, region: str, parcellation: str = None, showtree: bool = False):
"""Find brain regions by name"""
import siibra

Expand All @@ -203,13 +206,13 @@ def region(ctx, region, parcellation, tree):
else:
parcobj = atlas.get_parcellation(parcellation)
click.echo(f"Searching for region '{regionspec}' in {parcobj.name}.")
matches = parcobj.find_regions(regionspec)
matches = parcobj.find(regionspec)

if len(matches) == 0:
click.echo(f"No region found using the specification {regionspec}.")
exit(1)
for i, m in enumerate(matches):
txt = m.__repr__() if tree else m.name
txt = m.tree2str() if showtree else m.name
if parcellation is None:
click.echo(f"{i:5} | {m.parcellation.name:30.30} | {txt}")
else:
Expand Down Expand Up @@ -316,7 +319,7 @@ def coordinate(ctx, coordinate, space, parcellation, labelled, sigma_mm):
atlas = siibra.atlases[ctx.obj["species"]]
siibra.logger.info(f"Using atlas '{atlas.name}'.")
parcobj = atlas.get_parcellation(parcellation)
maptype = siibra.MapType.LABELLED if labelled else siibra.MapType.CONTINUOUS
maptype = siibra.MapType.LABELLED if labelled else siibra.MapType.STATISTICAL
requested_space = atlas.get_space(space)
location = siibra.Point(coordinate, space=requested_space)

Expand Down Expand Up @@ -347,5 +350,3 @@ def coordinate(ctx, coordinate, space, parcellation, labelled, sigma_mm):
click.echo(f"{region.name:40.40} {values}")
else:
click.echo(region.name)


0 comments on commit eb87d07

Please sign in to comment.