File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -460,7 +460,21 @@ def __init__(
460460 self .data = None if data is None else np .asarray (data )
461461 self .intent = intent_codes .code [intent ]
462462 if datatype is None :
463- datatype = 'none' if self .data is None else self .data .dtype
463+ if self .data is None :
464+ datatype = 'none'
465+ elif self .data .dtype in (
466+ np .dtype ('uint8' ),
467+ np .dtype ('int32' ),
468+ np .dtype ('float32' ),
469+ ):
470+ datatype = self .data .dtype
471+ else :
472+ raise ValueError (
473+ f'Data array has type { self .data .dtype } . '
474+ 'The GIFTI standard only supports uint8, int32 and float32 arrays.\n '
475+ 'Explicitly cast the data array to a supported dtype or pass an '
476+ 'explicit "datatype" parameter to GiftiDataArray().'
477+ )
464478 self .datatype = data_type_codes .code [datatype ]
465479 self .encoding = gifti_encoding_codes .code [encoding ]
466480 self .endian = gifti_endian_codes .code [endian ]
You can’t perform that action at this time.
0 commit comments