MCPcopy Index your code
hub / github.com/danjgale/surfplot / _check_data

Function _check_data

surfplot/plotting.py:104–120  ·  view source on GitHub ↗

Ensure that data is of appropriate type and return numpy array

(data)

Source from the content-addressed store, hash-verified

102
103
104def _check_data(data):
105 """Ensure that data is of appropriate type and return numpy array"""
106 if isinstance(data, np.ndarray):
107 return data.astype(float)
108 elif isinstance(data, (str, pathlib.PosixPath)):
109 data = nib.load(data)
110 elif isinstance(data, (nib.Cifti2Image, nib.GiftiImage)):
111 pass
112 else:
113 raise TypeError('data must be a file path to a valid GIFTI or CIFTI '
114 'file, or an instance of numpy.ndarray, '
115 'nibabel.Cifti2Image nibabel.GiftiImage')
116
117 if isinstance(data, nib.Cifti2Image):
118 return data.get_fdata().ravel().astype(float)
119 else:
120 return data.agg_data().ravel().astype(float)
121
122
123def _find_color_range(v):

Callers 1

add_layerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected