Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fea2cae
pyproject: create dep group for typechecking
kroq-gar78 Aug 11, 2026
8172960
pyproject: ignore packages without type annotations
kroq-gar78 Aug 11, 2026
b14e036
CI automatically save coverage with pytest
kroq-gar78 Feb 28, 2026
f99a411
Typing: Transform
kroq-gar78 Feb 28, 2026
67e1bbf
Transform: more specific annotation
kroq-gar78 Mar 4, 2026
f115f61
Typing: cortex/xfm.py
kroq-gar78 Mar 6, 2026
9f4c868
Monkeytype for cortex/volume.py
kroq-gar78 Mar 5, 2026
3e4df6c
xfm.py: better type
kroq-gar78 Aug 13, 2026
71f0e59
Some types for align
kroq-gar78 Mar 14, 2026
90c80ac
xfm.py: remove some Python 2 logic
kroq-gar78 Aug 13, 2026
69d30ee
nibabel types
kroq-gar78 Mar 14, 2026
42e4d5c
cortex.volume: partial type annots. Could be expanded more with dimen…
kroq-gar78 Apr 16, 2026
d761d61
volume.py: more specific types for unmask's MaskedArray return
kroq-gar78 Aug 13, 2026
d95e9f1
volume: use scipy.ndimage instead of deprecated interpolation shim (m…
kroq-gar78 Aug 11, 2026
f02d3dc
xfm/align: apply Transform.reference / reference_nifti changes from f…
kroq-gar78 Aug 13, 2026
e7f8298
Typing: formats.pyx
kroq-gar78 Feb 28, 2026
67d037c
Add type stub for formats.pyx . Unsure if the right approach
kroq-gar78 Mar 4, 2026
df6e85e
formats.pyi read_obj types
kroq-gar78 Apr 4, 2026
9ec41c7
Finish formats.pyi stub
kroq-gar78 Apr 4, 2026
1cfe1e1
Add types to Database
kroq-gar78 Apr 2, 2025
20f961b
database.py: add types to lots of things
kroq-gar78 Aug 13, 2026
bebc14b
Cleanup type annotations
kroq-gar78 Oct 1, 2025
af48680
Add surface-specific overloads for get_surf
kroq-gar78 Oct 2, 2025
2e6514a
Another attempt at get_surf
kroq-gar78 Dec 15, 2025
79f99ec
Fix types in database
kroq-gar78 Feb 28, 2026
a182a6a
database: specify numpy types
kroq-gar78 Mar 4, 2026
2fd8535
Hail mary to get Database.get_surf working
kroq-gar78 Mar 4, 2026
d9ed6eb
Narrower type for Database.get_mask
kroq-gar78 Mar 6, 2026
c2f012d
More cortex/database.py types
kroq-gar78 Mar 7, 2026
ae6eac1
database.py: fix some errors
kroq-gar78 Aug 13, 2026
9224a83
cortex/database.py: reduce typing errors
kroq-gar78 Mar 10, 2026
4e13a43
more Database types
kroq-gar78 Apr 4, 2026
eb7979c
database.py: annotate from movie-rendering pass
kroq-gar78 Aug 13, 2026
329d64a
database.py: more types shared with brainctm
kroq-gar78 Aug 13, 2026
d14208f
Cast nibabel to NifTI images to reduce type errors
kroq-gar78 Jun 6, 2026
49e48b5
database.py: apply Transform.reference_nifti change from fd711d8b
kroq-gar78 Aug 13, 2026
2c0c726
database: narrow literals, type auxfile fallback
kroq-gar78 Aug 13, 2026
afeb100
database.py: remove unused ignores
kroq-gar78 Aug 12, 2026
4556e6d
database: correct auxfile annotation to be Dataset
kroq-gar78 Aug 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pip-log.txt

# Unit test / coverage reports
.coverage
coverage.*
.tox
nosetests.xml

Expand Down
36 changes: 24 additions & 12 deletions cortex/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess as sp
import tempfile
import warnings
from typing import Literal, Optional

import numpy as np

Expand Down Expand Up @@ -107,8 +108,17 @@ def fs_manual(subject, xfmname, **kwargs):
return manual(subject, xfmname, **kwargs)


def manual(subject, xfmname, output_name="register.lta", wm_color="yellow",
pial_color="blue", wm_surface='white', noclean=False, reference=None, inspect_only=False):
def manual(
subject: str,
xfmname: str,
output_name: str = "register.lta",
wm_color: str = "yellow",
pial_color: str = "blue",
wm_surface: str = "white",
noclean: bool = False,
reference: Optional[str] = None,
inspect_only: bool = False,
) -> Optional[str]:
"""Open Freesurfer FreeView GUI for manually aligning/adjusting a functional
volume to the cortical surface for `subject`. This creates a new transform
called `xfmname`. The name of a nibabel-readable file (e.g. NIfTI) should be
Expand Down Expand Up @@ -191,7 +201,9 @@ def manual(subject, xfmname, output_name="register.lta", wm_color="yellow",

if reference is None:
# Load load extant transform-relevant things
reference = sub_xfm.reference.get_filename()
if sub_xfm.reference is None:
raise ValueError('Cannot inspect reference-free transform')
reference = sub_xfm.reference_nifti.get_filename()
_ = sub_xfm.to_freesurfer(os.path.join(cache, "register.dat"), subject) # Transform in freesurfer .dat format
# Command for FreeView and run
cmd = ("freeview -v $SUBJECTS_DIR/{sub}/mri/orig.mgz "
Expand Down Expand Up @@ -347,15 +359,15 @@ def automatic_fsl(


def automatic(
subject,
xfmname,
reference,
init="coreg",
epi_mask=False,
intermediate=None,
reference_contrast="t2",
noclean=False,
):
subject: str,
xfmname: str,
reference: str,
init: str = "coreg",
epi_mask: bool = False,
intermediate: Optional[str] = None,
reference_contrast: Literal['t1', 't2'] = "t2",
noclean: bool = False,
) -> Optional[str]:
"""Perform automatic alignment using Freesurfer's boundary-based registration.
The `reference` image and resulting transform called `xfmname` will be automatically
stored in the database.
Expand Down
Loading