diff --git a/README.md b/README.md index 8a52c17..6fde740 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,49 @@ Ruhr-Universität Bochum, Universitätsbibliothek 08.02.2024 [https://doi.org/10.13154/294-11032](https://doi.org/10.13154/294-11032) + +----------------------------------------------------------------------------------------------------- + +Updated: 19.03.2025 + +Files are now organized in subdirectories to distinguish better between code for GEVI or GECI analysis. +``` +gevi-geci/ + stage_1*, stage_2*, stage_3*, stage_4*, stage_5* + -> main stages for data preprocessing + -> use e.g.: python stage_1_get_ref_image.py -c config_example_GEVI.json + functions/ + -> functions used by the main stages + +gevi-geci/gevi/ + config_example_GEVI.json + -> typical config file for GEVI (compare to gevi-geci/geci/config_example_GECI.json) + config_M0134M*, config_M3905F* + -> config files for a few recordings (adjust directory names, if necessary!) + example_load_gevi.py + -> simple script demonstrating how to load data + +gevi-geci/geci/ + config_example_GECI.json + -> typical config file for GECI (compare to gevi-geci/gevi/config_example_GEVI.json) + config_M_Sert_Cre_4* + -> config files for a few recordings (adjust directory names, if necessary!) + stage_6_convert_roi.py + -> additional stage for the analysis of Hendrik's recordings + -> use e.g.: python stage_6_convert_roi.py -f config_M_Sert_Cre_41.json + geci_loader.py, geci_plot.py + -> additional code for summarizing the results and plotting with the ROIs + -> use e.g. python geci_loader.py --filename config_M_Sert_Cre_41.json + +gevi-geci/other/ + stage_4b_inspect.py, stage_4c_viewer.py + -> temporary code for assisting search for implantation electrode +``` + + + + + + + + diff --git a/config_M_Sert_Cre_41.json b/geci/config_M_Sert_Cre_41.json similarity index 78% rename from config_M_Sert_Cre_41.json rename to geci/config_M_Sert_Cre_41.json index 3675a3d..48ede27 100644 --- a/config_M_Sert_Cre_41.json +++ b/geci/config_M_Sert_Cre_41.json @@ -3,14 +3,14 @@ "recoding_data": "2023-07-17", "mouse_identifier": "M_Sert_Cre_41", "raw_path": "raw", - "export_path": "output_M_Sert_Cre_41", - "ref_image_path": "ref_images_M_Sert_Cre_41", - "heartbeat_remove": false, - "gevi": false, // true => gevi, false => geci + "export_path": "output/M_Sert_Cre_41", + "ref_image_path": "ref_images/M_Sert_Cre_41", + "heartbeat_remove": true, + "gevi": false, // true => gevi, false => geci // Ratio Sequence "classical_ratio_mode": true, // true: a/d false: 1+a-d // Regression - //"target_camera_acceptor": "acceptor", + // EMPTY FOR GECI "target_camera_acceptor": "acceptor", "target_camera_acceptor": "", "regressor_cameras_acceptor": [ "oxygenation", @@ -18,7 +18,7 @@ ], "target_camera_donor": "donor", "regressor_cameras_donor": [ - // "oxygenation", + // REMOVED FOR GECI "oxygenation", "volume" ], // binning @@ -52,6 +52,11 @@ "save_heartbeat": false, "save_factors": false, "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", @@ -59,4 +64,4 @@ "oxygenation", "volume" ] -} \ No newline at end of file +} diff --git a/config_M_Sert_Cre_42.json b/geci/config_M_Sert_Cre_42.json similarity index 78% rename from config_M_Sert_Cre_42.json rename to geci/config_M_Sert_Cre_42.json index 47d0ab6..daf6c3e 100644 --- a/config_M_Sert_Cre_42.json +++ b/geci/config_M_Sert_Cre_42.json @@ -3,14 +3,14 @@ "recoding_data": "2023-07-18", "mouse_identifier": "M_Sert_Cre_42", "raw_path": "raw", - "export_path": "output_M_Sert_Cre_42", - "ref_image_path": "ref_images_M_Sert_Cre_42", - "heartbeat_remove": false, - "gevi": false, // true => gevi, false => geci + "export_path": "output/M_Sert_Cre_42", + "ref_image_path": "ref_images/M_Sert_Cre_42", + "heartbeat_remove": true, + "gevi": false, // true => gevi, false => geci // Ratio Sequence "classical_ratio_mode": true, // true: a/d false: 1+a-d // Regression - //"target_camera_acceptor": "acceptor", + // EMPTY FOR GECI "target_camera_acceptor": "acceptor", "target_camera_acceptor": "", "regressor_cameras_acceptor": [ "oxygenation", @@ -18,7 +18,7 @@ ], "target_camera_donor": "donor", "regressor_cameras_donor": [ - // "oxygenation", + // REMOVED FOR GECI "oxygenation", "volume" ], // binning @@ -52,6 +52,11 @@ "save_heartbeat": false, "save_factors": false, "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", diff --git a/config_M_Sert_Cre_45.json b/geci/config_M_Sert_Cre_45.json similarity index 78% rename from config_M_Sert_Cre_45.json rename to geci/config_M_Sert_Cre_45.json index e28c337..875faf5 100644 --- a/config_M_Sert_Cre_45.json +++ b/geci/config_M_Sert_Cre_45.json @@ -3,14 +3,14 @@ "recoding_data": "2023-07-18", "mouse_identifier": "M_Sert_Cre_45", "raw_path": "raw", - "export_path": "output_M_Sert_Cre_45", - "ref_image_path": "ref_images_M_Sert_Cre_45", - "heartbeat_remove": false, - "gevi": false, // true => gevi, false => geci + "export_path": "output/M_Sert_Cre_45", + "ref_image_path": "ref_images/M_Sert_Cre_45", + "heartbeat_remove": true, + "gevi": false, // true => gevi, false => geci // Ratio Sequence "classical_ratio_mode": true, // true: a/d false: 1+a-d // Regression - //"target_camera_acceptor": "acceptor", + // EMPTY FOR GECI "target_camera_acceptor": "acceptor", "target_camera_acceptor": "", "regressor_cameras_acceptor": [ "oxygenation", @@ -18,7 +18,7 @@ ], "target_camera_donor": "donor", "regressor_cameras_donor": [ - // "oxygenation", + // REMOVED FOR GECI "oxygenation", "volume" ], // binning @@ -52,6 +52,11 @@ "save_heartbeat": false, "save_factors": false, "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", diff --git a/config_M_Sert_Cre_46.json b/geci/config_M_Sert_Cre_46.json similarity index 78% rename from config_M_Sert_Cre_46.json rename to geci/config_M_Sert_Cre_46.json index 21db1d5..085a80d 100644 --- a/config_M_Sert_Cre_46.json +++ b/geci/config_M_Sert_Cre_46.json @@ -3,14 +3,14 @@ "recoding_data": "2023-03-16", "mouse_identifier": "M_Sert_Cre_46", "raw_path": "raw", - "export_path": "output_M_Sert_Cre_46", - "ref_image_path": "ref_images_M_Sert_Cre_46", - "heartbeat_remove": false, - "gevi": false, // true => gevi, false => geci + "export_path": "output/M_Sert_Cre_46", + "ref_image_path": "ref_images/M_Sert_Cre_46", + "heartbeat_remove": true, + "gevi": false, // true => gevi, false => geci // Ratio Sequence "classical_ratio_mode": true, // true: a/d false: 1+a-d // Regression - //"target_camera_acceptor": "acceptor", + // EMPTY FOR GECI "target_camera_acceptor": "acceptor", "target_camera_acceptor": "", "regressor_cameras_acceptor": [ "oxygenation", @@ -18,7 +18,7 @@ ], "target_camera_donor": "donor", "regressor_cameras_donor": [ - // "oxygenation", + // REMOVED FOR GECI "oxygenation", "volume" ], // binning @@ -52,6 +52,11 @@ "save_heartbeat": false, "save_factors": false, "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", diff --git a/config_M_Sert_Cre_49.json b/geci/config_M_Sert_Cre_49.json similarity index 78% rename from config_M_Sert_Cre_49.json rename to geci/config_M_Sert_Cre_49.json index 2621f5e..11e6e8c 100644 --- a/config_M_Sert_Cre_49.json +++ b/geci/config_M_Sert_Cre_49.json @@ -3,14 +3,14 @@ "recoding_data": "2023-03-15", "mouse_identifier": "M_Sert_Cre_49", "raw_path": "raw", - "export_path": "output_M_Sert_Cre_49", - "ref_image_path": "ref_images_M_Sert_Cre_49", - "heartbeat_remove": false, - "gevi": false, // true => gevi, false => geci + "export_path": "output/M_Sert_Cre_49", + "ref_image_path": "ref_images/M_Sert_Cre_49", + "heartbeat_remove": true, + "gevi": false, // true => gevi, false => geci // Ratio Sequence "classical_ratio_mode": true, // true: a/d false: 1+a-d // Regression - //"target_camera_acceptor": "acceptor", + // EMPTY FOR GECI "target_camera_acceptor": "acceptor", "target_camera_acceptor": "", "regressor_cameras_acceptor": [ "oxygenation", @@ -18,7 +18,7 @@ ], "target_camera_donor": "donor", "regressor_cameras_donor": [ - // "oxygenation", + // REMOVED FOR GECI "oxygenation", "volume" ], // binning @@ -52,6 +52,11 @@ "save_heartbeat": false, "save_factors": false, "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", @@ -59,4 +64,4 @@ "oxygenation", "volume" ] -} \ No newline at end of file +} diff --git a/geci/config_example_GECI.json b/geci/config_example_GECI.json new file mode 100644 index 0000000..48ede27 --- /dev/null +++ b/geci/config_example_GECI.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/hendrik", + "recoding_data": "2023-07-17", + "mouse_identifier": "M_Sert_Cre_41", + "raw_path": "raw", + "export_path": "output/M_Sert_Cre_41", + "ref_image_path": "ref_images/M_Sert_Cre_41", + "heartbeat_remove": true, + "gevi": false, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + // EMPTY FOR GECI "target_camera_acceptor": "acceptor", + "target_camera_acceptor": "", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + // REMOVED FOR GECI "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/geci_loader.py b/geci/geci_loader.py similarity index 100% rename from geci_loader.py rename to geci/geci_loader.py diff --git a/geci_plot.py b/geci/geci_plot.py similarity index 100% rename from geci_plot.py rename to geci/geci_plot.py diff --git a/stage_6_convert_roi.py b/geci/stage_6_convert_roi.py similarity index 84% rename from stage_6_convert_roi.py rename to geci/stage_6_convert_roi.py index 18176db..7bedc29 100644 --- a/stage_6_convert_roi.py +++ b/geci/stage_6_convert_roi.py @@ -6,9 +6,7 @@ import numpy as np import h5py -def converter(config_filename: str = "config.json") -> None: - - filename: str = config_filename +def converter(filename: str = "config_M_Sert_Cre_49.json") -> None: if os.path.isfile(filename) is False: print(f"{filename} is missing") @@ -37,7 +35,7 @@ def converter(config_filename: str = "config.json") -> None: if os.path.isfile(roi_control_mat): hf = h5py.File(roi_control_mat, "r") roi_control = np.array(hf["roi"]).T - filename_out: str = f"roi_control{config["mouse_identifier"]}.npy" + filename_out: str = f"roi_control{config['mouse_identifier']}.npy" np.save(filename_out, roi_control) else: print("ROI Control not found") @@ -45,7 +43,7 @@ def converter(config_filename: str = "config.json") -> None: if os.path.isfile(roi_sdarken_mat): hf = h5py.File(roi_sdarken_mat, "r") roi_darken = np.array(hf["roi"]).T - filename_out = f"roi_sdarken{config["mouse_identifier"]}.npy" + filename_out: str = f"roi_sdarken{config['mouse_identifier']}.npy" np.save(filename_out, roi_darken) else: print("ROI sDarken not found") diff --git a/config_fatma_gevi_M0134M_SessionA2_Test.json b/gevi/config_M0134M_2024-11-06_SessionA.json similarity index 75% rename from config_fatma_gevi_M0134M_SessionA2_Test.json rename to gevi/config_M0134M_2024-11-06_SessionA.json index b1d0f83..b6f4da8 100644 --- a/config_fatma_gevi_M0134M_SessionA2_Test.json +++ b/gevi/config_M0134M_2024-11-06_SessionA.json @@ -1,12 +1,13 @@ { - "basic_path": "/data_1/fatma/GEVI", - "recoding_data": "2024-10-16", - "mouse_identifier": "M0134M_SessionA2_Test", - "export_path": "output_2024-10-16_M0134M_SessionA2_Test", - "ref_image_path": "ref_images_2024-10-16_M0134M_SessionA2_Test", + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-06", + "mouse_identifier": "M0134M_SessionA", "raw_path": "raw", - "heartbeat_remove": true, // if gevi must be true; geci: who knows... - "gevi": true, // true => gevi, false => geci + "export_path": "output/M0134M_2024-11-06_SessionA", + "ref_image_path": "ref_images/M0134M_2024-11-06_SessionA", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci // Ratio Sequence "classical_ratio_mode": true, // true: a/d false: 1+a-d // Regression @@ -51,6 +52,11 @@ "save_heartbeat": false, "save_factors": false, "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", diff --git a/gevi/config_M0134M_2024-11-06_SessionB.json b/gevi/config_M0134M_2024-11-06_SessionB.json new file mode 100644 index 0000000..b620fbd --- /dev/null +++ b/gevi/config_M0134M_2024-11-06_SessionB.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-06", + "mouse_identifier": "M0134M_SessionB", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-06_SessionB", + "ref_image_path": "ref_images/M0134M_2024-11-06_SessionB", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-11-07_SessionA.json b/gevi/config_M0134M_2024-11-07_SessionA.json new file mode 100644 index 0000000..01fb9b3 --- /dev/null +++ b/gevi/config_M0134M_2024-11-07_SessionA.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-07", + "mouse_identifier": "M0134M_SessionA", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-07_SessionA", + "ref_image_path": "ref_images/M0134M_2024-11-07_SessionA", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-11-07_SessionB.json b/gevi/config_M0134M_2024-11-07_SessionB.json new file mode 100644 index 0000000..d92b34b --- /dev/null +++ b/gevi/config_M0134M_2024-11-07_SessionB.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-07", + "mouse_identifier": "M0134M_SessionB", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-07_SessionB", + "ref_image_path": "ref_images/M0134M_2024-11-07_SessionB", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-11-13_SessionA.json b/gevi/config_M0134M_2024-11-13_SessionA.json new file mode 100644 index 0000000..eab7d1e --- /dev/null +++ b/gevi/config_M0134M_2024-11-13_SessionA.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-13", + "mouse_identifier": "M0134M_SessionA", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-13_SessionA", + "ref_image_path": "ref_images/M0134M_2024-11-13_SessionA", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-11-13_SessionB.json b/gevi/config_M0134M_2024-11-13_SessionB.json new file mode 100644 index 0000000..0ae7eab --- /dev/null +++ b/gevi/config_M0134M_2024-11-13_SessionB.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-13", + "mouse_identifier": "M0134M_SessionB", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-13_SessionB", + "ref_image_path": "ref_images/M0134M_2024-11-13_SessionB", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-11-15_SessionA.json b/gevi/config_M0134M_2024-11-15_SessionA.json new file mode 100644 index 0000000..c2aabf1 --- /dev/null +++ b/gevi/config_M0134M_2024-11-15_SessionA.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-15", + "mouse_identifier": "M0134M_SessionA", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-15_SessionA", + "ref_image_path": "ref_images/M0134M_2024-11-15_SessionA", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-11-15_SessionB.json b/gevi/config_M0134M_2024-11-15_SessionB.json new file mode 100644 index 0000000..3827bc9 --- /dev/null +++ b/gevi/config_M0134M_2024-11-15_SessionB.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-15", + "mouse_identifier": "M0134M_SessionB", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-15_SessionB", + "ref_image_path": "ref_images/M0134M_2024-11-15_SessionB", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/callum_config_M0134M.json b/gevi/config_M0134M_2024-11-18_SessionA.json similarity index 92% rename from callum_config_M0134M.json rename to gevi/config_M0134M_2024-11-18_SessionA.json index f283745..e9e0d00 100644 --- a/callum_config_M0134M.json +++ b/gevi/config_M0134M_2024-11-18_SessionA.json @@ -3,8 +3,8 @@ "recoding_data": "2024-11-18", "mouse_identifier": "M0134M_SessionA", "raw_path": "raw", - "export_path": "output_M0134M_SessionA", - "ref_image_path": "ref_images_M0134M_SessionA", + "export_path": "output/M0134M_2024-11-18_SessionA", + "ref_image_path": "ref_images/M0134M_2024-11-18_SessionA", "raw_path": "raw", "heartbeat_remove": true, "gevi": true, // true => gevi, false => geci @@ -56,6 +56,7 @@ "save_aligned_as_matlab": false, "save_oxyvol_as_python": false, "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", diff --git a/gevi/config_M0134M_2024-11-18_SessionB.json b/gevi/config_M0134M_2024-11-18_SessionB.json new file mode 100644 index 0000000..143817b --- /dev/null +++ b/gevi/config_M0134M_2024-11-18_SessionB.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-11-18", + "mouse_identifier": "M0134M_SessionB", + "raw_path": "raw", + "export_path": "output/M0134M_2024-11-18_SessionB", + "ref_image_path": "ref_images/M0134M_2024-11-18_SessionB", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-12-04_SessionA.json b/gevi/config_M0134M_2024-12-04_SessionA.json new file mode 100644 index 0000000..d77e531 --- /dev/null +++ b/gevi/config_M0134M_2024-12-04_SessionA.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-12-04", + "mouse_identifier": "M0134M_SessionA", + "raw_path": "raw", + "export_path": "output/M0134M_2024-12-04_SessionA", + "ref_image_path": "ref_images/M0134M_2024-12-04_SessionA", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/gevi/config_M0134M_2024-12-04_SessionB.json b/gevi/config_M0134M_2024-12-04_SessionB.json new file mode 100644 index 0000000..36ad83f --- /dev/null +++ b/gevi/config_M0134M_2024-12-04_SessionB.json @@ -0,0 +1,67 @@ +{ + "basic_path": "/data_1/fatma/GEVI/", + "recoding_data": "2024-12-04", + "mouse_identifier": "M0134M_SessionB", + "raw_path": "raw", + "export_path": "output/M0134M_2024-12-04_SessionB", + "ref_image_path": "ref_images/M0134M_2024-12-04_SessionB", + "raw_path": "raw", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci + // Ratio Sequence + "classical_ratio_mode": true, // true: a/d false: 1+a-d + // Regression + "target_camera_acceptor": "acceptor", + "regressor_cameras_acceptor": [ + "oxygenation", + "volume" + ], + "target_camera_donor": "donor", + "regressor_cameras_donor": [ + "oxygenation", + "volume" + ], + // binning + "binning_enable": true, + "binning_at_the_end": false, + "binning_kernel_size": 4, + "binning_stride": 4, + "binning_divisor_override": 1, + // alignment + "alignment_batch_size": 200, + "rotation_stabilization_threshold_factor": 3.0, // >= 1.0 + "rotation_stabilization_threshold_border": 0.9, // <= 1.0 + // Heart beat detection + "lower_freqency_bandpass": 5.0, // Hz + "upper_freqency_bandpass": 14.0, // Hz + "heartbeat_filtfilt_chuck_size": 10, + // Gauss smear + "gauss_smear_spatial_width": 8, + "gauss_smear_temporal_width": 0.1, + "gauss_smear_use_matlab_mask": false, + // LED Ramp on + "skip_frames_in_the_beginning": 100, // Frames + // PyTorch + "dtype": "float32", + "force_to_cpu": false, + // Save + "save_as_python": true, // produces .npz files (compressed) + "save_as_matlab": false, // produces .hd5 file (compressed) + // Save extra information + "save_alignment": false, + "save_heartbeat": false, + "save_factors": false, + "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, + // Not important parameter + "required_order": [ + "acceptor", + "donor", + "oxygenation", + "volume" + ] +} diff --git a/callum_config_M3905F.json b/gevi/config_M3905F_SessionB.json similarity index 89% rename from callum_config_M3905F.json rename to gevi/config_M3905F_SessionB.json index 8517026..f2a41bd 100644 --- a/callum_config_M3905F.json +++ b/gevi/config_M3905F_SessionB.json @@ -3,8 +3,8 @@ "recoding_data": "session_B", "mouse_identifier": "M3905F", "raw_path": "raw", - "export_path": "output_M3905F_session_B", - "ref_image_path": "ref_images_M3905F_session_B", + "export_path": "output/M3905F_SessionB", + "ref_image_path": "ref_images/M3905F_SessionB", "raw_path": "raw", "heartbeat_remove": true, "gevi": true, // true => gevi, false => geci @@ -54,8 +54,9 @@ "save_regression_coefficients": false, "save_aligned_as_python": false, "save_aligned_as_matlab": false, - "save_oxyvol_as_python": true, - "save_oxyvol_as_matlab": true, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", diff --git a/config_M3879M_2021-10-05.json b/gevi/config_example_GEVI.json similarity index 77% rename from config_M3879M_2021-10-05.json rename to gevi/config_example_GEVI.json index da3980a..e7d53ad 100644 --- a/config_M3879M_2021-10-05.json +++ b/gevi/config_example_GEVI.json @@ -1,12 +1,12 @@ { - "basic_path": "/data_1/robert", - "recoding_data": "2021-10-05", - "mouse_identifier": "M3879M", + "basic_path": "/data_1/fatma/GEVI_GECI_ES", + "recoding_data": "session_B", + "mouse_identifier": "M3905F", "raw_path": "raw", - "export_path": "output_M3879M_2021-10-05", - "ref_image_path": "ref_images_M3879M_2021-10-05", - "heartbeat_remove": true, // if gevi must be true; geci: who knows... - "gevi": true, // true => gevi, false => geci + "export_path": "output/M3905F_SessionB", + "ref_image_path": "ref_images/M3905F_SessionB", + "heartbeat_remove": true, + "gevi": true, // true => gevi, false => geci // Ratio Sequence "classical_ratio_mode": true, // true: a/d false: 1+a-d // Regression @@ -51,6 +51,11 @@ "save_heartbeat": false, "save_factors": false, "save_regression_coefficients": false, + "save_aligned_as_python": false, + "save_aligned_as_matlab": false, + "save_oxyvol_as_python": false, + "save_oxyvol_as_matlab": false, + "save_gevi_with_donor_acceptor": true, // Not important parameter "required_order": [ "acceptor", diff --git a/gevi/example_load_gevi.py b/gevi/example_load_gevi.py new file mode 100644 index 0000000..ce8c2e5 --- /dev/null +++ b/gevi/example_load_gevi.py @@ -0,0 +1,56 @@ +# %% +import numpy as np +import matplotlib.pyplot as plt +import os + +output_path = 'output' + +recording_name = 'M0134M_2024-12-04_SessionA' +n_trials_per_experiment = [30, 0, 30, 30, 30, 30, 30, 30, 30,] +name_experiment = ['none', 'visual', '2 uA', '5 uA', '7 uA', '10 uA', '15 uA', '30 uA', '60 uA'] + +# recording_name = 'M0134M_2024-11-06_SessionB' +# n_trials_per_experiment = [15, 15,] +# name_experiment = ['none', 'visual',] + +i_experiment = 8 + +r_avg = None +ad_avg = None +for i_trial in range(n_trials_per_experiment[i_experiment]): + + folder = output_path + os.sep + recording_name + file = f"Exp{i_experiment + 1:03}_Trial{i_trial + 1:03}_ratio_sequence.npz" + fullpath = folder + os.sep + file + + print(f'Loading file "{fullpath}"...') + data = np.load(fullpath) + + print(f"FIle contents: {data.files}") + ratio_sequence = data["ratio_sequence"] + if 'data_acceptor' in data.files: + data_acceptor = data["data_acceptor"] + data_donor = data["data_donor"] + + mask = data["mask"][:, :, np.newaxis] + + if i_trial == 0: + r_avg = ratio_sequence + if 'data_acceptor' in data.files: + ad_avg = (data_acceptor / data_donor) * mask + 1 - mask + else: + r_avg += ratio_sequence + if 'data_acceptor' in data.files: + ad_avg += (data_acceptor / data_donor) * mask + 1 - mask + +if r_avg is not None: + r_avg /= n_trials_per_experiment[i_experiment] +if ad_avg is not None: + ad_avg /= n_trials_per_experiment[i_experiment] + +# %% +for t in range(200, 300, 5): + plt.imshow(r_avg[:, :, t], vmin=0.99, vmax=1.01, cmap='seismic') + plt.colorbar() + plt.show() + diff --git a/stage_4b_inspect.py b/other/stage_4b_inspect.py similarity index 100% rename from stage_4b_inspect.py rename to other/stage_4b_inspect.py diff --git a/stage_4c_viewer.py b/other/stage_4c_viewer.py similarity index 100% rename from stage_4c_viewer.py rename to other/stage_4c_viewer.py diff --git a/preprocessing.pdf b/preprocessing.pdf new file mode 100644 index 0000000..701c122 Binary files /dev/null and b/preprocessing.pdf differ diff --git a/stage_5_convert_metadata.py b/stage_5_convert_metadata.py index 31e1ce2..9f4073b 100644 --- a/stage_5_convert_metadata.py +++ b/stage_5_convert_metadata.py @@ -6,15 +6,13 @@ from functions.get_trials import get_trials from functions.get_experiments import get_experiments -def converter(config_filename: str = "config.json") -> None: +def converter(config_filename: str = "config_M_Sert_Cre_49.json") -> None: - filename: str = config_filename - - if os.path.isfile(filename) is False: - print(f"{filename} is missing") + if os.path.isfile(config_filename) is False: + print(f"{config_filename} is missing") exit() - with open(filename, "r") as file: + with open(config_filename, "r") as file: config = json.loads(jsmin(file.read())) raw_data_path: str = os.path.join( @@ -30,6 +28,8 @@ def converter(config_filename: str = "config.json") -> None: experiments = get_experiments(raw_data_path).numpy() + os.makedirs(config["export_path"], exist_ok=True) + for experiment in experiments: trials = get_trials(raw_data_path, experiment).numpy() @@ -44,7 +44,10 @@ def converter(config_filename: str = "config.json") -> None: ) as file: metadata = json.loads(jsmin(file.read())) - filename_out: str = f"meta_{config["mouse_identifier"]}_exp{experiment:03d}.json" + filename_out: str = os.path.join( + config["export_path"], + f"metadata_exp{experiment:03d}.json", + ) with open(filename_out, 'w') as file: json.dump(metadata, file)