Skip to content

Commit 75a2906

Browse files
committed
fix: removed redundant file writing
1 parent 8b0feb6 commit 75a2906

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

nibabel/cifti/cifti.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,29 @@ def to_filename(self, filename):
796796
img = Nifti2Image(data, None, header)
797797
img.to_filename(filename)
798798

799+
800+
class CiftiDenseDataSeries(CiftiImage):
801+
"""Class to handle Dense Data Series
802+
803+
Dense Data Series
804+
-----------------
805+
806+
Intent_code: 3002, NIFTI_INTENT_CONNECTIVITY_DENSE_SERIES
807+
Intent_name: ConnDenseSeries
808+
File extension: .dtseries.nii
809+
AppliesToMatrixDimension 0: series
810+
AppliesToMatrixDimension 1: brain models
811+
812+
This file type represents data points in a series for every vertex and voxel
813+
in the mapping. A row is a complete data series,for a single vertex or
814+
voxel in the mapping that applies along the second dimension. A data series
815+
is often a timeseries, but it can also represent other data types such as a
816+
series of sampling depths along the surface normal from the white to pial
817+
surface. It retains the ‘t’ in dtseries from CIFTI-1 naming conventions.
818+
"""
819+
suffix = '.dtseries.nii'
820+
821+
799822
def load(filename):
800823
""" Load cifti2 from `filename`
801824

nibabel/cifti/parse_cifti_fast.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
CiftiMatrixIndicesMap, CiftiNamedMap, CiftiParcel,
2222
CiftiSurface, CiftiTransformationMatrixVoxelIndicesIJKtoXYZ,
2323
CiftiVertices, CiftiVolume, CIFTI_BrainStructures,
24-
CIFTI_MODEL_TYPES)
24+
CIFTI_MODEL_TYPES,
25+
CiftiDenseDataSeries)
2526

2627
DEBUG_PRINT = False
2728

@@ -371,8 +372,9 @@ def create_cifti_image(nifti2_image, cifti_header, intent_code):
371372
if ext.get_code() == 32:
372373
nifti_header.extensions.remove(ext)
373374
break
374-
with open('test.xml', 'wt') as fp:
375-
fp.writelines(cifti_header)
376375
header = parse_cifti_string(cifti_header)
377-
img = CiftiImage(data, header, nifti_header)
376+
if intent_code == 3002:
377+
img = CiftiDenseDataSeries(data, header, nifti_header)
378+
else:
379+
img = CiftiImage(data, header, nifti_header)
378380
return img

0 commit comments

Comments
 (0)