Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: CoordinateImage API#1090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
effigies wants to merge26 commits intonipy:master
base:master
Choose a base branch
Loading
fromeffigies:enh/coordimage_api
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
26 commits
Select commitHold shift + click to select a range
1b7df51
ENH: Start restoring triangular meshes
effigiesSep 19, 2023
5d25cef
TEST: Test basic TriangularMesh behavior
effigiesSep 20, 2023
e426afe
RF: Use order kwarg for array proxies
effigiesSep 20, 2023
1a46c70
TEST: Rework FreeSurferHemisphere and H5Geometry examples with mixin
effigiesSep 20, 2023
be05f09
TEST: Tag tests that require access to the data directory
effigiesSep 20, 2023
cbb91d1
RF: Allow coordinate names to be set on init
effigiesSep 22, 2023
107ead6
TEST: More fully test mesh and family APIs
effigiesSep 22, 2023
368c145
ENH: Avoid duplicating objects, note that coordinate family mappings …
effigiesSep 22, 2023
9d5361a
ENH: Add copy() method to ArrayProxy
effigiesSep 19, 2023
81b1033
ENH: Copy lock if filehandle is shared, add tests
effigiesSep 22, 2023
b70a4d9
Merge branches 'enh/copyarrayproxy', 'enh/xml-kwargs' and 'enh/triang…
effigiesSep 22, 2023
798f0c6
ENH: Add stubs from BIAP 9
effigiesFeb 18, 2022
7a6d50c
ENH: Implement CoordinateAxis. and Parcel.__getitem__
effigiesFeb 21, 2022
344bfd8
TEST: Add FreeSurferSubject geometry collection, test loading Cifti2 …
effigiesFeb 21, 2022
1138a95
ENH: Add CaretSpecFile type for use with CIFTI-2
effigiesFeb 22, 2022
c7ab610
TEST: Load CaretSpecFile as a GeometryCollection
effigiesFeb 22, 2022
a458ec3
ENH: Hacky mixin to make surface CaretDataFiles implement TriangularMesh
effigiesFeb 23, 2022
921173b
FIX: CoordinateAxis.__getitem__ fix
effigiesFeb 24, 2022
d4d42a0
ENH: Implement CoordinateAxis.get_indices
effigiesFeb 24, 2022
b51ec36
TEST: Add some assertions and smoke tests to exercise methods
effigiesFeb 24, 2022
76b52f5
ENH: Add from_image/from_header methods to bring logic out of tests
effigiesJan 25, 2023
1392a06
TEST: Add fsLR.wb.spec file for interpreting fsLR data
effigiesFeb 24, 2022
5edddd4
ENH: Add CoordinateImage slicing by parcel name
effigiesJan 25, 2023
05ca9fb
RF: Simplify CaretSpecParser slightly
effigiesFeb 25, 2022
6c2407d
TEST: Check SurfaceDataFile retrieval
effigiesAug 20, 2022
20f71df
Merge branch 'master' into enh/coordimage_api
effigiesJan 16, 2025
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
PrevPrevious commit
NextNext commit
RF: Allow coordinate names to be set on init
  • Loading branch information
@effigies
effigies committedSep 22, 2023
commitcbb91d1f9eb8a5768190bc313f82755f83c7df94
13 changes: 9 additions & 4 deletionsnibabel/pointset.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -169,17 +169,21 @@ def from_tuple(
mesh: tuple[CoordinateArray, CoordinateArray],
affine: np.ndarray | None = None,
homogeneous: bool = False,
**kwargs,
) -> Self:
return cls(mesh[0], mesh[1], affine=affine, homogeneous=homogeneous)
return cls(mesh[0], mesh[1], affine=affine, homogeneous=homogeneous, **kwargs)

@classmethod
def from_object(
cls,
mesh: HasMeshAttrs,
affine: np.ndarray | None = None,
homogeneous: bool = False,
**kwargs,
) -> Self:
return cls(mesh.coordinates, mesh.triangles, affine=affine, homogeneous=homogeneous)
return cls(
mesh.coordinates, mesh.triangles, affine=affine, homogeneous=homogeneous, **kwargs
)

@property
def n_triangles(self):
Expand All@@ -198,9 +202,10 @@ def get_mesh(self, *, as_homogeneous: bool = False):


class CoordinateFamilyMixin(Pointset):
def __init__(self, *args, **kwargs):
self._coords ={}
def __init__(self, *args,name='original',**kwargs):
mapping =kwargs.pop('mapping', {})
super().__init__(*args, **kwargs)
self._coords = {name: self.coordinates, **mapping}

def get_names(self):
"""List of surface names that can be passed to :meth:`with_name`"""
Expand Down
18 changes: 9 additions & 9 deletionsnibabel/tests/test_pointset.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -262,7 +262,7 @@ def __getitem__(self, slicer):
return h5f[self.dataset_name][slicer]


class H5Geometry(ps.TriangularMesh, ps.CoordinateFamilyMixin):
class H5Geometry(ps.CoordinateFamilyMixin, ps.TriangularMesh):
"""Simple Geometry file structure that combines a single topology
with one or more coordinate sets
"""
Expand All@@ -274,8 +274,7 @@ def from_filename(klass, pathlike):
triangles = H5ArrayProxy(pathlike, '/topology')
for name in h5f['coordinates']:
coords[name] = H5ArrayProxy(pathlike, f'/coordinates/{name}')
self = klass(next(iter(coords.values())), triangles)
self._coords.update(coords)
self = klass(next(iter(coords.values())), triangles, mapping=coords)
return self

def to_filename(self, pathlike):
Expand DownExpand Up@@ -336,13 +335,12 @@ def triangles(self):
)


class FreeSurferHemisphere(ps.TriangularMesh, ps.CoordinateFamilyMixin):
class FreeSurferHemisphere(ps.CoordinateFamilyMixin, ps.TriangularMesh):
@classmethod
def from_filename(klass, pathlike):
path = Path(pathlike)
hemi, default = path.name.split('.')
self = klass.from_object(FSGeometryProxy(path))
self._coords[default] = self.coordinates
self = klass.from_object(FSGeometryProxy(path), name=default)
mesh_names = (
'orig',
'white',
Expand All@@ -353,10 +351,12 @@ def from_filename(klass, pathlike):
'midthickness',
'graymid',
) # Often created

for mesh in mesh_names:
fpath = path.parent / f'{hemi}.{mesh}'
if mesh not in self._coords and fpath.exists():
self.add_coordinates(mesh, FSGeometryProxy(fpath).coordinates)
if mesh != default:
fpath = path.parent / f'{hemi}.{mesh}'
if fpath.exists():
self.add_coordinates(mesh, FSGeometryProxy(fpath).coordinates)
return self


Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp