neurodec.mdt.Image#

class neurodec.mdt.Image(dictionary: dict)#

A 3D image containing tissue information.

property id: int#

Returns the ID of the object

classmethod new(image: ArrayLike, voxel_sizes: Union[Tuple[float, float, float], ArrayLike], labels: dict, ignore_labels: Optional[Collection[int]] = None, skin_thickness: float = 0.002, force_computation: bool = False) Image#

Create a new 3D image.

Create a new 3D image. Once received on the server, it is processed so that its spatial resolution is as uniform as possible.

Parameters
  • image – A NumPy array of integers with a shape of (A, B, C) that contains voxels whose values represent labelled tissues. Each label should correspond to a specific component of the arm. See the argument ‘labels’ for more details.

  • voxel_sizes – A tuple or NumPy array that represents the spatial resolution of the image in the X, Y and Z directions. This is used to associate the voxel at coordinates (i, j, k) to the point in space with Cartesian coordinates (i*voxel_sizes[0], j*voxel_sizes[1], k*voxel_sizes[2]). If two of the values are equal and the remaining one is larger, then the image is pre-processed to increase the resolution in the coarsest direction. .. Important:: The resolution has to be given in meters.

  • labels – Dictionary that specifies what each label in the image corresponds to, in terms of tissues. More precisely, in each image one label should be used to identify skin, one for fat, a couple for the bones (most likely, radius and ulna), several labels to identify the different muscles. Optionally, one or more labels can be given to identify electrodes. Note that if electrodes are not part of an image, they can still be added later using the Electrode class. Labels should be given as a dictionary with the following keys and values: - TissueType.SKIN: the label for the skin, as a positive integer; - TissueType.FAT: the label for the fat, as a positive integer; - TissueType.BONE: the labels for the bones, as a list of positive integers (can be empty); - TissueType.MUSCLE: the labels for the muscles, as a list of positive integers; - TissueType.ELECTRODE: the labels for the electrodes, as a list of positive integers (can be empty). Labels must be unique. As an example, it is an error to have the label ‘42’ both as skin label and as part of the list of muscle labels. The label ‘0’ is a special value that is used to represent empty space and therefore cannot be used. Note that not all labels in the image need to be associated to a tissue. As an example, while creating an MRI, some markers may have been placed on the skin to identify reference locations. These markers are not part of the volume conductor and therefore their label can be ignored while extracting the tetrahedral mesh. In practice, all voxels in the image whose label does not appear in the labels variables are ignored and treated as if they represented void space (label ‘0’). For each of these, a warning is issued to prevent issues related to forgotten labels, unless they are explicitly included in the ignore_labels variable.

  • ignore_labels – List of labels that appear in the image, but not in labels, and that can be safely ignored without issuing a warning. By default, this list is empty, meaning that a warning is issued for every missing label.

  • skin_thickness – After increasing the resolution of the image, the skin is re-computed so that it wraps around the arm with the specified thickness (2mm by default).

  • force_computation – Boolean flag that allows to bypass a status check. Normally, the API would check if an object with the requested parameters was already present in the database. If this was the case, the API would not request its computation and would simply return its identifier. By setting this flag to True, the user can bypass this logic and force the computation of the resource even if it existed already. The main reason is to allow starting a calculation again in case of unexpected errors.

Returns

The new image. If another image with the same parameters already exits, that one will be returned instead of creating a new image.

property status: Status#

Returns the up-to-date status of the object, by performing an API request.

wait()#

Wait for the object to be ready