AcquisitionParams

from mcot.mde.xps import AcquisitionParams
class mcot.mde.xps.AcquisitionParams(*args, **kwargs)[source]
__init__(*args, **kwargs)[source]

Inheritance diagram

digraph inheritancec8ba116439 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "mcot.mde.xps.AcquisitionParams" [URL="#mcot.mde.xps.AcquisitionParams",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }

Methods

auto_update([check])

Applies all conversions and optionally check consistency in parameters

check()

clear()

copy()

from_json(filename)

Reads an XPS MDE structure from a JSON file

from_mat(filename)

Reads an XPS MDE structure from the matlab file

from_pandas(df)

Converts from a pandas dataframe to a dictionary

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

get_index([sort_by])

Indexes the volumes based on the parameters

groupby(indices[, drop])

Groups the parameters by the indices, taking the mean for all parameters

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

Remove and return a (key, value) pair as a 2-tuple.

read(filename)

Reads the acquisition parameters from a JSON or matlab file

read_bvals_bvecs(bvals_fn[, bvecs_fn, modality])

Converts bvals/bvecs file into an MDE XPS structure

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

to_json(filename)

Writes an XPS MDE structure to a JSON file

to_mat(filename)

Writes an XPS MDE to a matlab file

to_pandas()

Converts to a pandas dataframe (dropping any multi-dimensional parameters)

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

write(filename)

Writes the acquisition parameters to a JSON or matlab file

Attributes

n

Number of observations

auto_update

AcquisitionParams.auto_update(check=True)[source]

Applies all conversions and optionally check consistency in parameters

Returns itself

check

AcquisitionParams.check()[source]

clear

AcquisitionParams.clear() None.  Remove all items from D.

copy

AcquisitionParams.copy() a shallow copy of D

from_json

classmethod AcquisitionParams.from_json(filename: str) mcot.mde.xps.AcquisitionParams[source]

Reads an XPS MDE structure from a JSON file

Parameters

filename – .json file

Returns

XPS MDE structure

from_mat

classmethod AcquisitionParams.from_mat(filename: str) mcot.mde.xps.AcquisitionParams[source]

Reads an XPS MDE structure from the matlab file

Parameters

filename – .mat matlab structure produced by Markus Nilsson md-dmri library

Returns

XPS MDE structure

from_pandas

classmethod AcquisitionParams.from_pandas(df) mcot.mde.xps.AcquisitionParams[source]

Converts from a pandas dataframe to a dictionary

Parameters

df – pandas dataframe

Returns

fromkeys

AcquisitionParams.fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get

AcquisitionParams.get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

get_index

AcquisitionParams.get_index(sort_by=None, **parameters)[source]

Indexes the volumes based on the parameters

Parameters
  • parameters

    mapping of parameters to how different they are allowed to be, e.g.

    • xps.get_index(b=100) groups to data into shells with b-values within 100

    • xps.get_index(b=100, te=0) ensures that only volumes with the same TE will be assigned to a given shell

    • NaNs are in the same shell, but in a different shell from everything else

  • sort_by – name of the parameter to sort the indices by

Returns

(n, ) integer array with the indices (0-based)

groupby

AcquisitionParams.groupby(indices, drop=()) mcot.mde.xps.AcquisitionParams[source]

Groups the parameters by the indices, taking the mean for all parameters

Parameters
  • indices – indices grouping observations in shells (zero-based)

  • drop – parameters to drop

Returns

new acquisition parameters with one value per shell (total of max(indices) + 1)

items

AcquisitionParams.items() a set-like object providing a view on D's items

keys

AcquisitionParams.keys() a set-like object providing a view on D's keys

pop

AcquisitionParams.pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem

AcquisitionParams.popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

read

classmethod AcquisitionParams.read(filename: str)[source]

Reads the acquisition parameters from a JSON or matlab file

Parameters

filename – filename ending with .json or .mat

Returns

the stored MDE XPS structure

read_bvals_bvecs

classmethod AcquisitionParams.read_bvals_bvecs(bvals_fn, bvecs_fn=None, modality='LTE')[source]

Converts bvals/bvecs file into an MDE XPS structure

Parameters
  • bvals_fn – file with b-values

  • bvecs_fn – file with b-vectors

  • modality – modality (one of LTE, PTE, or STE)

Returns

XPS object

setdefault

AcquisitionParams.setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

to_json

AcquisitionParams.to_json(filename: str)[source]

Writes an XPS MDE structure to a JSON file

Parameters

filename – .json filename

to_mat

AcquisitionParams.to_mat(filename: str)[source]

Writes an XPS MDE to a matlab file

Parameters

filename – .mat matlab structure readable by Markus Nilsson md-dmri library

to_pandas

AcquisitionParams.to_pandas()[source]

Converts to a pandas dataframe (dropping any multi-dimensional parameters)

Returns

resulting dataframe

update

AcquisitionParams.update([E, ]**F) None.  Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values

AcquisitionParams.values() an object providing a view on D's values

write

AcquisitionParams.write(filename: str)[source]

Writes the acquisition parameters to a JSON or matlab file

Parameters

filename – filename ending with .json or .mat

Returns

the stored MDE XPS structure