neurocarto.util.edit.data

neurocarto.util.edit.data.load_data(self, file)

Load a data array.

support data type

  • numpy file (‘.npy’) with shape Array[float, E].

  • csv file (‘.csv’, ‘.tsv’) with reader shank,x,y,value.

  • data file supported by ProbeDesp. load_blueprint().

    The value is read from category field.

Neuropixels

For the Neuropixels, NpxProbeDesp use the numpy array in this form:

Array[int, E, (shank, col, row, state, category)]

Because E’s category is expected as an int, this method also take it as an int by default.

Parameters:
Returns:

Array[float, E] data array, where E is all electrodes.

See:

BlueprintFunctions. load_data()

See:

load_csv_data()

See:

load_date_from_blueprint()

Return type:

ndarray[tuple[int, …], dtype[float64]]

neurocarto.util.edit.data.load_csv_data(self, file, *, comments='#', delimiter=',')

Load electrode data array from a csv file.

Header

shank,x,y,value

where shank could also use s, and value field can be arbitrary word.

Parameters:
  • self (BlueprintFunctions)

  • file (str | Path) – csv file.

  • comments (str) – default '#'.

  • delimiter (str) – default ','.

Returns:

Array[float, E] data array, where E is all electrodes.

Raises:

IOError – unknown csv header.

Raise:

other error raised by np.loadtxt.

See:

BlueprintFunctions. load_data()

Return type:

ndarray[tuple[int, …], dtype[float64]]

neurocarto.util.edit.data.load_date_from_blueprint_file(self, file)
Parameters:
neurocarto.util.edit.data.save_data(self, file, value)

Save a numpy data array.

support data type

  • csv file (‘.csv’, ‘.tsv’) with reader shank,x,y,value.

  • data file supported by ProbeDesp. load_blueprint().

    The data value is stored into the category field.

If no specific requirement, consider use numpy.save first.

Neuropixels

For the Neuropixels, NpxProbeDesp use the numpy array in this form:

Array[int, E, (shank, col, row, state, category)]

Because E’s category is expected as an int, this method will cast it into an int by default.

Parameters:
  • file (str | Path) – data file

  • data – Array[float, E] data array, where E is all electrodes.

  • self (BlueprintFunctions)

  • value (ndarray[tuple[int, ...], dtype[float64]])

See:

BlueprintFunctions. save_data()

See:

save_csv_data()

See:

load_date_from_blueprint_file()

neurocarto.util.edit.data.save_csv_data(self, file, data, *, comments='#', delimiter=',')

Save electrode data into a csv file.

Header

shank,x,y,value

Parameters:
  • self (BlueprintFunctions)

  • file (str | Path) – csv filepath

  • data (ndarray[tuple[int, ...], dtype[float64]]) – Array[float, E] data array, where E is all electrodes.

  • comments (str) – default '#'.

  • delimiter (str) – default ','.

Raise:

other error raised by np.savetxt.

neurocarto.util.edit.data.save_data_into_blueprint_file(self, file, value)
Parameters:
  • self (BlueprintFunctions)

  • file (str | Path)

  • value (ndarray[tuple[int, ...], dtype[float64]])

neurocarto.util.edit.data.interpolate_nan(self, a, kernel=1, f='mean')

Interpolate the NaN value in the data a.

Warning

this method works different with interpolate_nan() on

  • this method works on 1-d array, but the latter one works on 2-d or 3-d array.

  • TBD

Parameters:
  • a (ndarray[tuple[int, ...], dtype[float64]]) – data array.

  • kernel (int | tuple[int, int]) – kernel size.

  • f (str | Callable[[ndarray[tuple[int, ...], dtype[float64]]], float]) – interpolate method. Default use mean.

  • self (BlueprintFunctions)

Returns:

interpolated data.

See:

BlueprintFunctions. interpolate_nan()

Return type:

ndarray[tuple[int, …], dtype[float64]]