spacr.mediar — spacr 0.5.0 documentation

# spacr.mediar

## Module Contents

spacr.mediar.mediar_path

spacr.mediar.init_file

spacr.mediar.display_imgs_in_list(lists_of_imgs, cmaps=None)

  Displays images from multiple lists side by side. Each row will display one image from each list (lists_of_imgs[i][j] is the j-th image in the i-th list).

  Parameters:

    - lists_of_imgs – A list of lists, where each inner list contains images.

    - cmaps – List of colormaps to use for each list (optional). If not provided, defaults to ‘gray’ for all lists.

spacr.mediar.get_weights(finetuned_weights=False)

spacr.mediar.normalize_image(image, lower_percentile=0.0, upper_percentile=99.5)

  Normalize an image based on the 0.0 and 99.5 percentiles.

  Parameters:

    - image – Input image (numpy array).

    - lower_percentile – Lower percentile (default is 0.0).

    - upper_percentile – Upper percentile (default is 99.5).

  Returns:

    Normalized image (numpy array).

class spacr.mediar.MEDIARPredictor(input_path=None, output_path=None, device=None, model='ensemble', roi_size=512, overlap=0.6, finetuned_weights=False, test=False, use_tta=False, normalize=True, quantiles=[0.0, 99.5])
  device = None
  test = False
  model = 'ensemble'
  normalize = True
  quantiles = [0.0, 99.5]
  model1
  model2
  load_model(model_path, device)
  display_image_and_mask(img, mask)
  predict_batch(imgs)

    Predict masks for a batch of images.

    Parameters:

      imgs – List of input images as NumPy arrays (each in (H, W, C) format).

    Returns:

      List of predicted masks as NumPy arrays.

  run_test()

    Run the model on test images if the test flag is True.

  preprocess_image(img)

    Preprocess input image (numpy array) for compatibility with the model.