spacr 0.1.63__py3-none-any.whl → 0.1.75__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
spacr/settings.py CHANGED
@@ -43,7 +43,7 @@ def set_default_settings_preprocess_generate_masks(src, settings={}):
43
43
  settings.setdefault('magnification', 20)
44
44
  settings.setdefault('custom_regex', None)
45
45
  settings.setdefault('metadata_type', 'cellvoyager')
46
- settings.setdefault('workers', os.cpu_count()-4)
46
+ settings.setdefault('n_job', os.cpu_count()-4)
47
47
  settings.setdefault('randomize', True)
48
48
  settings.setdefault('verbose', True)
49
49
  settings.setdefault('remove_background_cell', False)
@@ -219,6 +219,7 @@ def set_default_umap_image_settings(settings={}):
219
219
  def get_measure_crop_settings(settings):
220
220
 
221
221
  settings.setdefault('src', 'path')
222
+ settings.setdefault('verbose', False)
222
223
 
223
224
  # Test mode
224
225
  settings.setdefault('test_mode', False)
@@ -253,7 +254,7 @@ def get_measure_crop_settings(settings):
253
254
  settings.setdefault('plot',False)
254
255
  settings.setdefault('plot_filtration',False)
255
256
  settings.setdefault('representative_images', False)
256
- settings.setdefault('max_workers', os.cpu_count()-2)
257
+ settings.setdefault('n_job', os.cpu_count()-2)
257
258
 
258
259
  # Object settings
259
260
  settings.setdefault('cell_mask_dim',None)
@@ -282,6 +283,7 @@ def get_measure_crop_settings(settings):
282
283
  settings.setdefault('um_per_pixel', 0.1)
283
284
 
284
285
  if settings['test_mode']:
286
+ settings['verbose'] = True
285
287
  settings['plot'] = True
286
288
  settings['plot_filtration'] = True
287
289
  test_imgs = settings['test_nr']
@@ -338,7 +340,7 @@ def set_default_train_test_model(settings):
338
340
  settings.setdefault('gradient_accumulation_steps',4)
339
341
  settings.setdefault('intermedeate_save',True)
340
342
  settings.setdefault('pin_memory',True)
341
- settings.setdefault('num_workers',cores)
343
+ settings.setdefault('n_job',cores)
342
344
  settings.setdefault('channels',['r','g','b'])
343
345
  settings.setdefault('augment',False)
344
346
  settings.setdefault('verbose',False)
@@ -488,266 +490,264 @@ def get_identify_masks_finetune_default_settings(settings):
488
490
  return settings
489
491
 
490
492
  q = None
493
+ expected_types = {
494
+ "src": str,
495
+ "metadata_type": str,
496
+ "custom_regex": (str, type(None)),
497
+ "experiment": str,
498
+ "channels": list,
499
+ "magnification": int,
500
+ "nucleus_channel": (int, type(None)),
501
+ "nucleus_background": int,
502
+ "nucleus_Signal_to_noise": float,
503
+ "nucleus_CP_prob": float,
504
+ "nucleus_FT": float,
505
+ "cell_channel": (int, type(None)),
506
+ "cell_background": (int, float),
507
+ "cell_Signal_to_noise": (int, float),
508
+ "cell_CP_prob": (int, float),
509
+ "cell_FT": (int, float),
510
+ "pathogen_channel": (int, type(None)),
511
+ "pathogen_background": (int, float),
512
+ "pathogen_Signal_to_noise": (int, float),
513
+ "pathogen_CP_prob": (int, float),
514
+ "pathogen_FT": (int, float),
515
+ "preprocess": bool,
516
+ "masks": bool,
517
+ "examples_to_plot": int,
518
+ "randomize": bool,
519
+ "batch_size": int,
520
+ "timelapse": bool,
521
+ "timelapse_displacement": int,
522
+ "timelapse_memory": int,
523
+ "timelapse_frame_limits": list, # This can be a list of lists
524
+ "timelapse_remove_transient": bool,
525
+ "timelapse_mode": str,
526
+ "timelapse_objects": list,
527
+ "fps": int,
528
+ "remove_background": bool,
529
+ "lower_percentile": (int, float),
530
+ "merge_pathogens": bool,
531
+ "normalize_plots": bool,
532
+ "all_to_mip": bool,
533
+ "pick_slice": bool,
534
+ "skip_mode": str,
535
+ "save": bool,
536
+ "plot": bool,
537
+ "n_job": int,
538
+ "verbose": bool,
539
+ "input_folder": str,
540
+ "cell_mask_dim": int,
541
+ "cell_min_size": int,
542
+ "cytoplasm_min_size": int,
543
+ "nucleus_mask_dim": int,
544
+ "nucleus_min_size": int,
545
+ "pathogen_mask_dim": int,
546
+ "pathogen_min_size": int,
547
+ "save_png": bool,
548
+ "crop_mode": list,
549
+ "use_bounding_box": bool,
550
+ "png_size": list, # This can be a list of lists
551
+ "normalize": bool,
552
+ "png_dims": list,
553
+ "normalize_by": str,
554
+ "save_measurements": bool,
555
+ "representative_images": bool,
556
+ "plot_filtration": bool,
557
+ "include_uninfected": bool,
558
+ "dialate_pngs": bool,
559
+ "dialate_png_ratios": list,
560
+ "n_job": int,
561
+ "cells": list,
562
+ "cell_loc": list,
563
+ "pathogens": list,
564
+ "pathogen_loc": (list, list), # This can be a list of lists
565
+ "treatments": list,
566
+ "treatment_loc": (list, list), # This can be a list of lists
567
+ "channel_of_interest": int,
568
+ "compartments": list,
569
+ "measurement": str,
570
+ "nr_imgs": int,
571
+ "um_per_pixel": (int, float),
572
+ # Additional settings based on provided defaults
573
+ "include_noninfected": bool,
574
+ "include_multiinfected": bool,
575
+ "include_multinucleated": bool,
576
+ "filter_min_max": (list, type(None)),
577
+ "channel_dims": list,
578
+ "backgrounds": list,
579
+ "outline_thickness": int,
580
+ "outline_color": str,
581
+ "overlay_chans": list,
582
+ "overlay": bool,
583
+ "normalization_percentiles": list,
584
+ "print_object_number": bool,
585
+ "nr": int,
586
+ "figuresize": int,
587
+ "cmap": str,
588
+ "test_mode": bool,
589
+ "test_images": int,
590
+ "remove_background_cell": bool,
591
+ "remove_background_nucleus": bool,
592
+ "remove_background_pathogen": bool,
593
+ "pathogen_model": (str, type(None)),
594
+ "filter": bool,
595
+ "upscale": bool,
596
+ "upscale_factor": float,
597
+ "adjust_cells": bool,
598
+ "row_limit": int,
599
+ "tables": list,
600
+ "visualize": str,
601
+ "image_nr": int,
602
+ "dot_size": int,
603
+ "n_neighbors": int,
604
+ "min_dist": float,
605
+ "metric": str,
606
+ "eps": float,
607
+ "min_samples": int,
608
+ "filter_by": str,
609
+ "img_zoom": float,
610
+ "plot_by_cluster": bool,
611
+ "plot_cluster_grids": bool,
612
+ "remove_cluster_noise": bool,
613
+ "remove_highly_correlated": bool,
614
+ "log_data": bool,
615
+ "black_background": bool,
616
+ "remove_image_canvas": bool,
617
+ "plot_outlines": bool,
618
+ "plot_points": bool,
619
+ "smooth_lines": bool,
620
+ "clustering": str,
621
+ "exclude": (str, type(None)),
622
+ "col_to_compare": str,
623
+ "pos": str,
624
+ "neg": str,
625
+ "embedding_by_controls": bool,
626
+ "plot_images": bool,
627
+ "reduction_method": str,
628
+ "save_figure": bool,
629
+ "color_by": (str, type(None)),
630
+ "analyze_clusters": bool,
631
+ "resnet_features": bool,
632
+ "test_nr": int,
633
+ "radial_dist": bool,
634
+ "calculate_correlation": bool,
635
+ "manders_thresholds": list,
636
+ "homogeneity": bool,
637
+ "homogeneity_distances": list,
638
+ "save_arrays": bool,
639
+ "cytoplasm": bool,
640
+ "merge_edge_pathogen_cells": bool,
641
+ "cells_per_well": int,
642
+ "pathogen_size_range": list,
643
+ "nucleus_size_range": list,
644
+ "cell_size_range": list,
645
+ "pathogen_intensity_range": list,
646
+ "nucleus_intensity_range": list,
647
+ "cell_intensity_range": list,
648
+ "target_intensity_min": int,
649
+ "model_type": str,
650
+ "heatmap_feature": str,
651
+ "grouping": str,
652
+ "min_max": str,
653
+ "minimum_cell_count": int,
654
+ "n_estimators": int,
655
+ "test_size": float,
656
+ "location_column": str,
657
+ "positive_control": str,
658
+ "negative_control": str,
659
+ "n_repeats": int,
660
+ "top_features": int,
661
+ "remove_low_variance_features": bool,
662
+ "n_jobs": int,
663
+ "classes": list,
664
+ "schedule": str,
665
+ "loss_type": str,
666
+ "image_size": int,
667
+ "epochs": int,
668
+ "val_split": float,
669
+ "train_mode": str,
670
+ "learning_rate": float,
671
+ "weight_decay": float,
672
+ "dropout_rate": float,
673
+ "init_weights": bool,
674
+ "amsgrad": bool,
675
+ "use_checkpoint": bool,
676
+ "gradient_accumulation": bool,
677
+ "gradient_accumulation_steps": int,
678
+ "intermedeate_save": bool,
679
+ "pin_memory": bool,
680
+ "n_job": int,
681
+ "augment": bool,
682
+ "target": str,
683
+ "cell_types": list,
684
+ "cell_plate_metadata": (list, type(None)),
685
+ "pathogen_types": list,
686
+ "pathogen_plate_metadata": (list, list), # This can be a list of lists
687
+ "treatment_plate_metadata": (list, list), # This can be a list of lists
688
+ "metadata_types": list,
689
+ "cell_chann_dim": int,
690
+ "nucleus_chann_dim": int,
691
+ "pathogen_chann_dim": int,
692
+ "plot_nr": int,
693
+ "plot_control": bool,
694
+ "remove_background": bool,
695
+ "target": str,
696
+ "upstream": str,
697
+ "downstream": str,
698
+ "barecode_length_1": int,
699
+ "barecode_length_2": int,
700
+ "chunk_size": int,
701
+ "grna": str,
702
+ "barcodes": str,
703
+ "plate_dict": dict,
704
+ "pc": str,
705
+ "pc_loc": str,
706
+ "nc": str,
707
+ "nc_loc": str,
708
+ "dependent_variable": str,
709
+ "transform": (str, type(None)),
710
+ "agg_type": str,
711
+ "min_cell_count": int,
712
+ "regression_type": str,
713
+ "remove_row_column_effect": bool,
714
+ "alpha": float,
715
+ "fraction_threshold": float,
716
+ "class_1_threshold": (float, type(None)),
717
+ "batch_size": int,
718
+ "CP_prob": float,
719
+ "flow_threshold": float,
720
+ "percentiles": (list, type(None)),
721
+ "circular": bool,
722
+ "invert": bool,
723
+ "diameter": int,
724
+ "grayscale": bool,
725
+ "resize": bool,
726
+ "target_height": (int, type(None)),
727
+ "target_width": (int, type(None)),
728
+ "rescale": bool,
729
+ "resample": bool,
730
+ "model_name": str,
731
+ "Signal_to_noise": int,
732
+ "learning_rate": float,
733
+ "weight_decay": float,
734
+ "batch_size": int,
735
+ "n_epochs": int,
736
+ "from_scratch": bool,
737
+ "width_height": list,
738
+ "resize": bool,
739
+ "gene_weights_csv": str,
740
+ "fraction_threshold": float,
741
+ }
491
742
 
492
- def check_settings(vars_dict):
493
- global q
743
+ def check_settings_v1(vars_dict, expected_types,q=None):
494
744
  from .gui_utils import parse_list
495
745
  settings = {}
496
746
  # Define the expected types for each key, including None where applicable
497
- expected_types = {
498
- "src": str,
499
- "metadata_type": str,
500
- "custom_regex": (str, type(None)),
501
- "experiment": str,
502
- "channels": list,
503
- "magnification": int,
504
- "nucleus_channel": (int, type(None)),
505
- "nucleus_background": int,
506
- "nucleus_Signal_to_noise": float,
507
- "nucleus_CP_prob": float,
508
- "nucleus_FT": float,
509
- "cell_channel": (int, type(None)),
510
- "cell_background": (int, float),
511
- "cell_Signal_to_noise": (int, float),
512
- "cell_CP_prob": (int, float),
513
- "cell_FT": (int, float),
514
- "pathogen_channel": (int, type(None)),
515
- "pathogen_background": (int, float),
516
- "pathogen_Signal_to_noise": (int, float),
517
- "pathogen_CP_prob": (int, float),
518
- "pathogen_FT": (int, float),
519
- "preprocess": bool,
520
- "masks": bool,
521
- "examples_to_plot": int,
522
- "randomize": bool,
523
- "batch_size": int,
524
- "timelapse": bool,
525
- "timelapse_displacement": int,
526
- "timelapse_memory": int,
527
- "timelapse_frame_limits": list, # This can be a list of lists
528
- "timelapse_remove_transient": bool,
529
- "timelapse_mode": str,
530
- "timelapse_objects": list,
531
- "fps": int,
532
- "remove_background": bool,
533
- "lower_percentile": (int, float),
534
- "merge_pathogens": bool,
535
- "normalize_plots": bool,
536
- "all_to_mip": bool,
537
- "pick_slice": bool,
538
- "skip_mode": str,
539
- "save": bool,
540
- "plot": bool,
541
- "workers": int,
542
- "verbose": bool,
543
- "input_folder": str,
544
- "cell_mask_dim": int,
545
- "cell_min_size": int,
546
- "cytoplasm_min_size": int,
547
- "nucleus_mask_dim": int,
548
- "nucleus_min_size": int,
549
- "pathogen_mask_dim": int,
550
- "pathogen_min_size": int,
551
- "save_png": bool,
552
- "crop_mode": list,
553
- "use_bounding_box": bool,
554
- "png_size": list, # This can be a list of lists
555
- "normalize": bool,
556
- "png_dims": list,
557
- "normalize_by": str,
558
- "save_measurements": bool,
559
- "representative_images": bool,
560
- "plot_filtration": bool,
561
- "include_uninfected": bool,
562
- "dialate_pngs": bool,
563
- "dialate_png_ratios": list,
564
- "max_workers": int,
565
- "cells": list,
566
- "cell_loc": list,
567
- "pathogens": list,
568
- "pathogen_loc": (list, list), # This can be a list of lists
569
- "treatments": list,
570
- "treatment_loc": (list, list), # This can be a list of lists
571
- "channel_of_interest": int,
572
- "compartments": list,
573
- "measurement": str,
574
- "nr_imgs": int,
575
- "um_per_pixel": (int, float),
576
- # Additional settings based on provided defaults
577
- "include_noninfected": bool,
578
- "include_multiinfected": bool,
579
- "include_multinucleated": bool,
580
- "filter_min_max": (list, type(None)),
581
- "channel_dims": list,
582
- "backgrounds": list,
583
- "outline_thickness": int,
584
- "outline_color": str,
585
- "overlay_chans": list,
586
- "overlay": bool,
587
- "normalization_percentiles": list,
588
- "print_object_number": bool,
589
- "nr": int,
590
- "figuresize": int,
591
- "cmap": str,
592
- "test_mode": bool,
593
- "test_images": int,
594
- "remove_background_cell": bool,
595
- "remove_background_nucleus": bool,
596
- "remove_background_pathogen": bool,
597
- "pathogen_model": (str, type(None)),
598
- "filter": bool,
599
- "upscale": bool,
600
- "upscale_factor": float,
601
- "adjust_cells": bool,
602
- "row_limit": int,
603
- "tables": list,
604
- "visualize": str,
605
- "image_nr": int,
606
- "dot_size": int,
607
- "n_neighbors": int,
608
- "min_dist": float,
609
- "metric": str,
610
- "eps": float,
611
- "min_samples": int,
612
- "filter_by": str,
613
- "img_zoom": float,
614
- "plot_by_cluster": bool,
615
- "plot_cluster_grids": bool,
616
- "remove_cluster_noise": bool,
617
- "remove_highly_correlated": bool,
618
- "log_data": bool,
619
- "black_background": bool,
620
- "remove_image_canvas": bool,
621
- "plot_outlines": bool,
622
- "plot_points": bool,
623
- "smooth_lines": bool,
624
- "clustering": str,
625
- "exclude": (str, type(None)),
626
- "col_to_compare": str,
627
- "pos": str,
628
- "neg": str,
629
- "embedding_by_controls": bool,
630
- "plot_images": bool,
631
- "reduction_method": str,
632
- "save_figure": bool,
633
- "color_by": (str, type(None)),
634
- "analyze_clusters": bool,
635
- "resnet_features": bool,
636
- "test_nr": int,
637
- "radial_dist": bool,
638
- "calculate_correlation": bool,
639
- "manders_thresholds": list,
640
- "homogeneity": bool,
641
- "homogeneity_distances": list,
642
- "save_arrays": bool,
643
- "cytoplasm": bool,
644
- "merge_edge_pathogen_cells": bool,
645
- "cells_per_well": int,
646
- "pathogen_size_range": list,
647
- "nucleus_size_range": list,
648
- "cell_size_range": list,
649
- "pathogen_intensity_range": list,
650
- "nucleus_intensity_range": list,
651
- "cell_intensity_range": list,
652
- "target_intensity_min": int,
653
- "model_type": str,
654
- "heatmap_feature": str,
655
- "grouping": str,
656
- "min_max": str,
657
- "minimum_cell_count": int,
658
- "n_estimators": int,
659
- "test_size": float,
660
- "location_column": str,
661
- "positive_control": str,
662
- "negative_control": str,
663
- "n_repeats": int,
664
- "top_features": int,
665
- "remove_low_variance_features": bool,
666
- "n_jobs": int,
667
- "classes": list,
668
- "schedule": str,
669
- "loss_type": str,
670
- "image_size": int,
671
- "epochs": int,
672
- "val_split": float,
673
- "train_mode": str,
674
- "learning_rate": float,
675
- "weight_decay": float,
676
- "dropout_rate": float,
677
- "init_weights": bool,
678
- "amsgrad": bool,
679
- "use_checkpoint": bool,
680
- "gradient_accumulation": bool,
681
- "gradient_accumulation_steps": int,
682
- "intermedeate_save": bool,
683
- "pin_memory": bool,
684
- "num_workers": int,
685
- "augment": bool,
686
- "target": str,
687
- "cell_types": list,
688
- "cell_plate_metadata": (list, type(None)),
689
- "pathogen_types": list,
690
- "pathogen_plate_metadata": (list, list), # This can be a list of lists
691
- "treatment_plate_metadata": (list, list), # This can be a list of lists
692
- "metadata_types": list,
693
- "cell_chann_dim": int,
694
- "nucleus_chann_dim": int,
695
- "pathogen_chann_dim": int,
696
- "plot_nr": int,
697
- "plot_control": bool,
698
- "remove_background": bool,
699
- "target": str,
700
- "upstream": str,
701
- "downstream": str,
702
- "barecode_length_1": int,
703
- "barecode_length_2": int,
704
- "chunk_size": int,
705
- "grna": str,
706
- "barcodes": str,
707
- "plate_dict": dict,
708
- "pc": str,
709
- "pc_loc": str,
710
- "nc": str,
711
- "nc_loc": str,
712
- "dependent_variable": str,
713
- "transform": (str, type(None)),
714
- "agg_type": str,
715
- "min_cell_count": int,
716
- "regression_type": str,
717
- "remove_row_column_effect": bool,
718
- "alpha": float,
719
- "fraction_threshold": float,
720
- "class_1_threshold": (float, type(None)),
721
- "batch_size": int,
722
- "CP_prob": float,
723
- "flow_threshold": float,
724
- "percentiles": (list, type(None)),
725
- "circular": bool,
726
- "invert": bool,
727
- "diameter": int,
728
- "grayscale": bool,
729
- "resize": bool,
730
- "target_height": (int, type(None)),
731
- "target_width": (int, type(None)),
732
- "rescale": bool,
733
- "resample": bool,
734
- "model_name": str,
735
- "Signal_to_noise": int,
736
- "learning_rate": float,
737
- "weight_decay": float,
738
- "batch_size": int,
739
- "n_epochs": int,
740
- "from_scratch": bool,
741
- "width_height": list,
742
- "resize": bool,
743
- "gene_weights_csv": str,
744
- "fraction_threshold": float,
745
- }
746
747
 
747
748
  for key, (label, widget, var) in vars_dict.items():
748
749
  if key not in expected_types:
749
750
  if key not in ["General","Nucleus","Cell","Pathogen","Timelapse","Plot","Object Image","Annotate Data","Measurements","Advanced","Miscellaneous","Test"]:
750
-
751
751
  q.put(f"Key {key} not found in expected types.")
752
752
  continue
753
753
 
@@ -794,6 +794,64 @@ def check_settings(vars_dict):
794
794
 
795
795
  return settings
796
796
 
797
+ def check_settings(vars_dict, expected_types, q=None):
798
+ from .gui_utils import parse_list
799
+
800
+ if q is None:
801
+ from multiprocessing import Queue
802
+ q = Queue()
803
+
804
+ settings = {}
805
+
806
+ for key, (label, widget, var) in vars_dict.items():
807
+ if key not in expected_types:
808
+ if key not in ["General", "Nucleus", "Cell", "Pathogen", "Timelapse", "Plot", "Object Image", "Annotate Data", "Measurements", "Advanced", "Miscellaneous", "Test"]:
809
+ q.put(f"Key {key} not found in expected types.")
810
+ continue
811
+
812
+ value = var.get()
813
+ expected_type = expected_types.get(key, str)
814
+
815
+ try:
816
+ if key in ["png_size", "pathogen_plate_metadata", "treatment_plate_metadata"]:
817
+ parsed_value = ast.literal_eval(value) if value else None
818
+ if isinstance(parsed_value, list):
819
+ if all(isinstance(i, list) for i in parsed_value) or all(not isinstance(i, list) for i in parsed_value):
820
+ settings[key] = parsed_value
821
+ else:
822
+ raise ValueError("Invalid format: Mixed list and list of lists")
823
+ else:
824
+ raise ValueError("Invalid format for list or list of lists")
825
+ elif expected_type == list:
826
+ settings[key] = parse_list(value) if value else None
827
+ elif expected_type == bool:
828
+ settings[key] = value if isinstance(value, bool) else value.lower() in ['true', '1', 't', 'y', 'yes']
829
+ elif expected_type == (int, type(None)):
830
+ settings[key] = int(value) if value else None
831
+ elif expected_type == (float, type(None)):
832
+ settings[key] = float(value) if value else None
833
+ elif expected_type == (int, float):
834
+ settings[key] = float(value) if '.' in value else int(value)
835
+ elif expected_type == (str, type(None)):
836
+ settings[key] = str(value) if value else None
837
+ elif isinstance(expected_type, tuple):
838
+ for typ in expected_type:
839
+ try:
840
+ settings[key] = typ(value) if value else None
841
+ break
842
+ except (ValueError, TypeError):
843
+ continue
844
+ else:
845
+ raise ValueError
846
+ else:
847
+ settings[key] = expected_type(value) if value else None
848
+ except (ValueError, SyntaxError) as e:
849
+ expected_type_name = ' or '.join([t.__name__ for t in expected_type]) if isinstance(expected_type, tuple) else expected_type.__name__
850
+ q.put(f"Error: Invalid format for {key}. Expected type: {expected_type_name}. Error: {e}")
851
+ return
852
+
853
+ return settings
854
+
797
855
  def generate_fields(variables, scrollable_frame):
798
856
  from .gui_utils import create_input_field
799
857
  from .gui_elements import spacrToolTip
@@ -844,7 +902,7 @@ def generate_fields(variables, scrollable_frame):
844
902
  "save": "Whether to save the results to disk.",
845
903
  "merge_edge_pathogen_cells": "Whether to merge cells that share pathogen objects.",
846
904
  "plot": "Whether to plot the results.",
847
- "workers": "The number of workers to use for processing the images. This will determine how many images are processed in parallel. Increase to speed up processing.",
905
+ "n_job": "The number of n_job to use for processing the images. This will determine how many images are processed in parallel. Increase to speed up processing.",
848
906
  "verbose": "Whether to print verbose output during processing.",
849
907
  "input_folder": "Path to the folder containing the images.",
850
908
  "cell_mask_dim": "The dimension of the array the cell mask is saved in.",
@@ -868,7 +926,7 @@ def generate_fields(variables, scrollable_frame):
868
926
  "include_uninfected": "Whether to include uninfected cells in the analysis.",
869
927
  "dialate_pngs": "Whether to dilate the PNG images before saving.",
870
928
  "dialate_png_ratios": "The ratios to use for dilating the PNG images. This will determine the amount of dilation applied to the images before cropping.",
871
- "max_workers": "The number of workers to use for processing the images. This will determine how many images are processed in parallel. Increase to speed up processing.",
929
+ "n_job": "The number of n_job to use for processing the images. This will determine how many images are processed in parallel. Increase to speed up processing.",
872
930
  "cells": "The cell types to include in the analysis.",
873
931
  "cell_loc": "The locations of the cell types in the images.",
874
932
  "pathogens": "The pathogen types to include in the analysis.",
@@ -897,12 +955,12 @@ categories = {
897
955
  "Nucleus": ["nucleus_channel", "nucleus_background", "nucleus_Signal_to_noise", "nucleus_CP_prob", "nucleus_FT", "remove_background_nucleus", "nucleus_min_size", "nucleus_mask_dim", "nucleus_loc"],
898
956
  "Cell": ["cell_channel", "cell_background", "cell_Signal_to_noise", "cell_CP_prob", "cell_FT", "remove_background_cell", "cell_min_size", "cell_mask_dim", "cytoplasm", "cytoplasm_min_size", "include_uninfected", "merge_edge_pathogen_cells", "adjust_cells"],
899
957
  "Pathogen": ["pathogen_channel", "pathogen_background", "pathogen_Signal_to_noise", "pathogen_CP_prob", "pathogen_FT", "pathogen_model", "remove_background_pathogen", "pathogen_min_size", "pathogen_mask_dim"],
900
- "Timelapse": ["timelapse", "fps", "timelapse_displacement", "timelapse_memory", "timelapse_frame_limits", "timelapse_remove_transient", "timelapse_mode", "timelapse_objects", "compartments"],
901
- "Plot": ["plot_filtration", "examples_to_plot", "normalize_plots", "normalize", "cmap", "figuresize", "plot", "plot_cluster_grids", "img_zoom", "row_limit", "color_by", "plot_images", "smooth_lines", "plot_points", "plot_outlines", "black_background", "plot_by_cluster", "heatmap_feature","grouping","min_max","cmap","save_figure"],
958
+ "Timelapse": ["fps", "timelapse_displacement", "timelapse_memory", "timelapse_frame_limits", "timelapse_remove_transient", "timelapse_mode", "timelapse_objects", "compartments"],
959
+ "Plot": ["plot_filtration", "examples_to_plot", "normalize_plots", "normalize", "cmap", "figuresize", "plot_cluster_grids", "img_zoom", "row_limit", "color_by", "plot_images", "smooth_lines", "plot_points", "plot_outlines", "black_background", "plot_by_cluster", "heatmap_feature","grouping","min_max","cmap","save_figure"],
902
960
  "Object Image": ["save_png", "dialate_pngs", "dialate_png_ratios", "png_size", "png_dims", "save_arrays", "normalize_by", "dialate_png_ratios", "crop_mode", "dialate_pngs", "normalize", "use_bounding_box"],
903
961
  "Annotate Data": ["positive_control","negative_control", "location_column", "treatment_loc", "cells", "cell_loc", "pathogens", "pathogen_loc", "channel_of_interest", "measurement", "treatments", "representative_images", "um_per_pixel", "nr_imgs", "exclude", "exclude_conditions", "mix", "pos", "neg"],
904
962
  "Measurements": ["remove_image_canvas", "remove_highly_correlated", "homogeneity", "homogeneity_distances", "radial_dist", "calculate_correlation", "manders_thresholds", "save_measurements", "tables", "image_nr", "dot_size", "filter_by", "remove_highly_correlated_features", "remove_low_variance_features", "channel_of_interest"],
905
- "Advanced": ["schedule", "test_size","exclude","n_repeats","top_features","n_jobs", "model_type","minimum_cell_count","n_estimators","preprocess", "remove_background", "normalize", "lower_percentile", "merge_pathogens", "batch_size", "filter", "save", "masks", "verbose", "randomize", "max_workers", "workers", "train_mode","amsgrad","use_checkpoint","gradient_accumulation","gradient_accumulation_steps","intermedeate_save","pin_memory","num_workers","channels","augment"],
963
+ "Advanced": ["plot", "timelapse", "schedule", "test_size","exclude","n_repeats","top_features", "model_type","minimum_cell_count","n_estimators","preprocess", "remove_background", "normalize", "lower_percentile", "merge_pathogens", "batch_size", "filter", "save", "masks", "verbose", "randomize", "n_job", "train_mode","amsgrad","use_checkpoint","gradient_accumulation","gradient_accumulation_steps","intermedeate_save","pin_memory","n_job","channels","augment"],
906
964
  "Clustering": ["eps","min_samples","analyze_clusters","clustering","remove_cluster_noise"],
907
965
  "Embedding": ["visualize","n_neighbors","min_dist","metric","resnet_features","reduction_method","embedding_by_controls","col_to_compare","log_data"],
908
966
  "Train DL Model": ["epochs", "loss_type", "optimizer_type","image_size","val_split","learning_rate","weight_decay","dropout_rate","init_weights", "train", "classes"],
@@ -910,3 +968,18 @@ categories = {
910
968
  "Test": ["test_mode", "test_images", "random_test", "test_nr"],
911
969
  "Sequencing": ["upstream", "downstream", "barecode_length_1", "barecode_length_2", "chunk_size", "test"]
912
970
  }
971
+
972
+ def set_annotate_default_settings(settings):
973
+ settings.setdefault('src', 'path')
974
+ settings.setdefault('image_type', 'cell_png')
975
+ settings.setdefault('channels', 'r,g,b')
976
+ settings.setdefault('geom', "3200x2000")
977
+ settings.setdefault('img_size', [200, 200])
978
+ settings.setdefault('rows', 10)
979
+ settings.setdefault('columns', 18)
980
+ settings.setdefault('annotation_column', 'test')
981
+ settings.setdefault('normalize', 'False')
982
+ settings.setdefault('percentiles', [2, 98])
983
+ settings.setdefault('measurement', 'cytoplasm_channel_3_mean_intensity,pathogen_channel_3_mean_intensity')
984
+ settings.setdefault('threshold', '2')
985
+ return settings
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spacr
3
- Version: 0.1.63
3
+ Version: 0.1.75
4
4
  Summary: Spatial phenotype analysis of crisp screens (SpaCr)
5
5
  Home-page: https://github.com/EinarOlafsson/spacr
6
6
  Author: Einar Birnir Olafsson