-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from MICA-MNI/121-test-the-ci-workflow
for test purpose
- Loading branch information
Showing
11 changed files
with
83 additions
and
31 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* @zihuaihuai | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,11 @@ | |
# Author: Oualid Benkarim <[email protected]> | ||
# License: BSD 3 clause | ||
|
||
|
||
import numpy as np | ||
from vtk import vtkPolyData | ||
from vtk.util.vtkAlgorithm import VTKPythonAlgorithmBase | ||
|
||
|
||
from ..decorators import wrap_input | ||
from ...mesh.mesh_creation import build_polydata | ||
|
||
|
@@ -52,22 +53,39 @@ def _read_gifti(ipth, ipths_pointdata): | |
|
||
@wrap_input(0) | ||
def _write_gifti(pd, opth): | ||
# TODO: what about pointdata? | ||
import numpy as np | ||
from nibabel.gifti.gifti import GiftiDataArray | ||
from nibabel.nifti1 import data_type_codes | ||
|
||
if not pd.has_only_triangle: | ||
raise ValueError('GIFTI writer only accepts triangles.') | ||
|
||
points = GiftiDataArray(data=pd.Points, intent=INTENT_POINTS) | ||
cells = GiftiDataArray(data=pd.GetCells2D(), intent=INTENT_CELLS) | ||
# if data is not None: | ||
# data_array = GiftiDataArray(data=data, intent=INTENT_POINTDATA) | ||
# gii = nb.gifti.GiftiImage(darrays=[points, cells, data_array]) | ||
# else: | ||
# Cast Points to float32 | ||
points_data = pd.Points.astype(np.float32) | ||
points_datatype = data_type_codes[points_data.dtype] | ||
points = GiftiDataArray( | ||
data=points_data, | ||
intent=INTENT_POINTS, | ||
datatype=points_datatype | ||
) | ||
|
||
# Cast Cells to int32 | ||
cells_data = pd.GetCells2D().astype(np.int32) | ||
cells_datatype = data_type_codes[cells_data.dtype] | ||
cells = GiftiDataArray( | ||
data=cells_data, | ||
intent=INTENT_CELLS, | ||
datatype=cells_datatype | ||
) | ||
|
||
# Create the GIFTI image | ||
g = nb.gifti.GiftiImage(darrays=[points, cells]) | ||
|
||
# Save the GIFTI image | ||
nb.save(g, opth) | ||
|
||
|
||
|
||
############################################################################### | ||
# VTK Reader and Writer for GIFTI surfaces | ||
############################################################################### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,9 @@ | |
# Author: Oualid Benkarim <[email protected]> | ||
# License: BSD 3 clause | ||
|
||
|
||
import vtk | ||
from vtk.util.vtkConstants import VTK_STRING, VTK_UNSIGNED_CHAR | ||
from vtk.util.numpy_support import numpy_to_vtk | ||
|
||
from .base import BSVTKObjectWrapper | ||
from ..decorators import unwrap_input | ||
|
@@ -31,7 +32,10 @@ def __init__(self, vtkobject=None, **kwargs): | |
|
||
@unwrap_input(1, vtype={1: VTK_UNSIGNED_CHAR}) | ||
def SetTable(self, table): | ||
self.VTKObject.SetTable(table) | ||
# Convert NumPy array to vtkUnsignedCharArray | ||
vtk_table = numpy_to_vtk(table, array_type=vtk.VTK_UNSIGNED_CHAR, deep=True) | ||
# Now set the table using the vtkUnsignedCharArray | ||
self.VTKObject.SetTable(vtk_table) | ||
|
||
def SetNumberOfColors(self, n): | ||
# SetNumberOfColors() has no effect after the table has been built | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters