microglia_analyzer.tiles.recalibrate module

microglia_analyzer.tiles.recalibrate.get_net2ori_factor(output_px_size, output_unit)[source]

Get the scaling factor to convert the UNet pixel size (0.325 µm) to the output pixel size.

Parameters:
  • output_px_size (float) – The pixel size of the output image.

  • output_unit (str) – The unit of the output pixel size.

Returns:

The scaling factor to convert the UNet pixel size to the output pixel size.

Return type:

float

microglia_analyzer.tiles.recalibrate.get_ori2net_factor(input_px_size, input_unit)[source]

Get the scaling factor to convert the input pixel size to the UNet pixel size (0.325 µm).

Parameters:
  • input_px_size (float) – The pixel size of the input image.

  • input_unit (str) – The unit of the input pixel size.

Returns:

The scaling factor to convert the input pixel size to the UNet pixel size.

Return type:

float

microglia_analyzer.tiles.recalibrate.process_factor(input_px_size, input_unit, output_px_size, output_unit)[source]

Process the scaling factor to convert the input pixel size to the output pixel size.

Parameters:
  • input_px_size (float) – The pixel size of the input image.

  • input_unit (str) – The unit of the input pixel size.

  • output_px_size (float) – The pixel size of the output image.

  • output_unit (str) – The unit of the output pixel size.

Returns:

The scaling factor to convert the input pixel size to the output pixel size.

Return type:

float

microglia_analyzer.tiles.recalibrate.recalibrate_shape(input_shape, input_px_size, input_unit, output_px_size, output_unit)[source]

Takes the shape of an image and its calibration to process its shape with another calibration. The number of channels (C) is not modified, only the Y and X dimensions are recalibrated.

Parameters:
  • input_shape (tuple) – The shape of the input image.

  • input_px_size (float) – The pixel size of the input image.

  • input_unit (str) – The unit of the input pixel size.

  • output_px_size (float) – The pixel size of the output image.

  • output_unit (str) – The unit of the output pixel size.

Returns:

The recalibrated shape.

Return type:

tuple

class microglia_analyzer.tiles.recalibrate.scaling[source]

Bases: object

class from_calibration[source]

Bases: object

static net2ori(data, pixel_size, unit, inter=True)[source]

Scales an image having a pixel size of 0.325µm to the original pixel size. Made to convert the UNet’s output (“network”) to something having the original pixel size (“original”).

Parameters:
  • data (np.array) – The image to scale, with a pixel size of 0.325µm.

  • pixel_size (float) – The target pixel size to reach with the scaling.

  • unit (str) – The unit of the pixel size.

  • inter (bool) – Whether to use interpolation or not. Defaults to True.

Returns:

The scaled image with the target pixel size.

Return type:

np.array

static ori2net(data, pixel_size, unit, inter=True)[source]

Scales an image to simulate a pixel size of 0.325 µm. Made to convert an input image (“original”) to something that the UNet (“network”) can process.

Parameters:
  • data (np.array) – The image to scale, with a pixel size that is not 0.325µm.

  • pixel_size (float) – The pixel size of the ‘data’ image.

  • unit (str) – The unit of the pixel size.

  • inter (bool) – Whether to use interpolation or not. Defaults to True.

Returns:

The scaled image with a pixel size of 0.325µm.

Return type:

np.array

static from_shape(data, shape, inter=True)[source]

Scales an image to mimic a pixel size of 0.325 µm. Made to convert an input image (“original”) to something that the UNet (“network”) can process.

Parameters:
  • data (np.array) – The image to scale, with a pixel size that is not 0.325µm.

  • shape (tuple) – The target shape to reach with the scaling.

  • inter (bool) – Whether to use interpolation or not. Defaults to True.

Returns:

The scaled image with a pixel size of 0.325µm.

Return type:

np.array