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

Commit021e5de

Browse files
committed
RF: Extract nifti header update fromto_filename
1 parent1f6a608 commit021e5de

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

‎nibabel/cifti2/cifti2.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,11 @@ def update_headers(self):
15451545
>>> img.shape == (2, 3, 4)
15461546
True
15471547
"""
1548-
self._nifti_header.set_data_shape((1,1,1,1)+self._dataobj.shape)
1548+
header=self._nifti_header
1549+
header.set_data_shape((1,1,1,1)+self._dataobj.shape)
1550+
# if intent code is not set, default to unknown
1551+
ifheader.get_intent()[0]=='none':
1552+
header.set_intent('NIFTI_INTENT_CONNECTIVITY_UNKNOWN')
15491553

15501554
defget_data_dtype(self):
15511555
returnself._nifti_header.get_data_dtype()
@@ -1565,8 +1569,6 @@ def to_filename(self, filename, validate=True):
15651569
for the expected IndicesMaps attributes.
15661570
If validation fails, an error will be raised instead.
15671571
"""
1568-
nheader=self._nifti_header
1569-
# try to infer intent code based on filename suffix
15701572
ifvalidate:
15711573
ext=_extract_cifti_extension(filename)
15721574
try:
@@ -1576,7 +1578,7 @@ def to_filename(self, filename, validate=True):
15761578
f"Validation failed: No information for extension{ext} available"
15771579
)fromerr
15781580
intent=CIFTI_CODES.niistring[ext]
1579-
nheader.set_intent(intent)
1581+
self._nifti_header.set_intent(intent)
15801582
# validate matrix indices
15811583
foridx,mtypeinenumerate(CIFTI_CODES.map_types[ext]):
15821584
try:
@@ -1586,9 +1588,6 @@ def to_filename(self, filename, validate=True):
15861588
f"Validation failed: Cifti2Matrix index map{idx} does "
15871589
f"not match expected type{mtype}"
15881590
)
1589-
# if intent code is not set, default to unknown
1590-
ifnheader.get_intent()[0]=='none':
1591-
nheader.set_intent('NIFTI_INTENT_CONNECTIVITY_UNKNOWN')
15921591
super().to_filename(filename)
15931592

15941593

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp