Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to automatically remove units which trigger similarity #305

Open
abuzarmahmood opened this issue Jan 10, 2025 · 2 comments
Open

Option to automatically remove units which trigger similarity #305

abuzarmahmood opened this issue Jan 10, 2025 · 2 comments

Comments

@abuzarmahmood
Copy link
Collaborator

Can be added as a paramter to the sorting config

@abuzarmahmood
Copy link
Collaborator Author

Also add mean time difference between spike times

@abuzarmahmood
Copy link
Collaborator Author

To address the issue of adding an option to automatically remove units that trigger similarity as a parameter to the sorting configuration, the following suggestions and changes were made:

  1. Relevant Files:

    • blech_clust.py: This is the main script for processing and clustering neural recording data. It handles HDF5 file operations and generates processing scripts. Modifications here involve adding a parameter to the sorting configuration to handle unit similarity.
    • blech_post_process_utils.py: This module provides utilities for handling and processing electrophysiological data, focusing on sorting and clustering spike data. It includes functions for managing sort files and handling unit descriptors, relevant for implementing unit similarity checks.
    • unit_similarity.py: This module analyzes unit similarity in neural spike data, identifying and reporting units with high similarity. It processes data from HDF5 files, calculates similarity matrices, and generates visualizations and reports. This file is directly related to the issue of unit similarity.
  2. Changes Suggested:

    • Add a Parameter to the Sorting Configuration:
      In blech_clust.py, add a new parameter to the sorting configuration to handle unit similarity by modifying the parameter file or adding a command-line argument:

      # Add a new argument for removing similar units
      parser.add_argument('--remove_similar_units', action='store_true', help='Automatically remove units with high similarity')

      This should be added around line 46.

    • Implement Logic to Remove Similar Units:
      In unit_similarity.py, implement the logic to automatically remove units based on similarity criteria by modifying the parse_collision_mat function:

      def parse_collision_mat(unit_distances, similarity_cutoff, remove_similar_units=False):
          similar_units = list(zip(*np.where(unit_distances > similarity_cutoff)))
          similar_units = [x for x in similar_units if x[0] != x[1]]
          unique_pairs = []
          unique_pairs_collisions = []
          for this_pair in similar_units:
              if this_pair not in unique_pairs and this_pair[::-1] not in unique_pairs:
                  unique_pairs.append(this_pair)
                  unique_pairs_collisions.append(unit_distances[this_pair])
                  if remove_similar_units:
                      # Logic to remove one of the units in the pair
                      # This could involve removing the unit from the HDF5 file or marking it for removal
                      pass
          return unique_pairs, unique_pairs_collisions

      This modification should be made around line 104.

    • Integrate the Parameter in the Main Execution Block:
      In the main execution block of unit_similarity.py, check for the remove_similar_units parameter and pass it to the parse_collision_mat function:

      if __name__ == '__main__':
          # Other code...
          remove_similar_units = '--remove_similar_units' in sys.argv
          unique_pairs, unique_pairs_collisions = parse_collision_mat(unit_distances, similarity_cutoff, remove_similar_units)
          # Other code...

      This should be added around line 239.

By implementing these changes, an option to automatically remove units that trigger similarity as a parameter to the sorting configuration will be added, allowing users to enable or disable this feature as needed.


This response was automatically generated by blech_bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant