1. Generate Segmentation Masks

In [1]:

  from spacr.core import preprocess_generate_masks
  %matplotlib inline

  settings = {
    'src':'/home/olafsson/datasets/plate1',
    'metadata_type':'cellvoyager',
    'custom_regex':None,
    'experiment':'screen',
    'channels':[0,1,2,3],
    'cell_channel':3,
    'cell_background':100,
    'cell_Signal_to_noise':10,
    'cell_CP_prob':-1,
    'remove_background_cell':False,
    'nucleus_channel':0,
    'nucleus_background':200,
    'nucleus_Signal_to_noise':5,
    'nucleus_CP_prob':0,
    'remove_background_nucleus':False,
    'pathogen_model':None,
    'pathogen_channel':2,
    'pathogen_background':400,
    'pathogen_Signal_to_noise':5,
    'pathogen_CP_prob':-2,
    'remove_background_pathogen':True,
    'consolidate':False,
    'magnification':40,
    'save':True,
    'preprocess':True,
    'masks':True,
    'batch_size':50,
    'filter':False,
    'merge_pathogens':False,
    'plot':True,
    'adjust_cells':True,
    'test_mode':True,
    'test_images':10,
    'random_test':True
  }
  
This code block sets up and launches the mask generation process in test mode using spaCR. Hover over each line to learn what it does.
channels
>>> Running mask generation...
>>> Loading model: Cellpose cyto
>>> Processing image batch 1/3...
>>> Completed: 10 images analyzed.
    
This slide demonstrates the initial mask generation using the Cellpose 'cyto' model. Note the high signal-to-noise ratio achieved by preprocessing with background removal and normalization enabled.
channels
>>> Using settings:
>>>   cell_channel=3, nucleus_channel=0
>>>   background=[100, 200], SNR=[10, 5]
>>> Executing test mode with 10 random images.
    
Test mode is useful for validating segmentation settings before processing the entire dataset. This helps identify optimal Cellpose parameters like diameter, probability threshold, and SNR settings.
channels
>>> Finished mask generation.
>>> Masks saved to: /home/user/output/masks/
>>> Object features extracted and saved to database.
    
Final results show successfully saved mask outputs. You can now proceed to object classification, visualization, or export for downstream spatial analyses.
channels
>>> Using settings:
>>>   cell_channel=3, nucleus_channel=0
>>>   background=[100, 200], SNR=[10, 5]
>>> Executing test mode with 10 random images.
    
Test mode is useful for validating segmentation settings before processing the entire dataset. This helps identify optimal Cellpose parameters like diameter, probability threshold, and SNR settings.
channels
>>> Using settings:
>>>   cell_channel=3, nucleus_channel=0
>>>   background=[100, 200], SNR=[10, 5]
>>> Executing test mode with 10 random images.
    
Test mode is useful for validating segmentation settings before processing the entire dataset. This helps identify optimal Cellpose parameters like diameter, probability threshold, and SNR settings.