This tool provides a graphical user interface for visualizing neural data recorded from Neuropixel probes. It allows users to load specific channels of data, navigate through the recording in time, and visualize voltage traces for selected channels.
- Load and visualize data from Neuropixel recordings
- Select specific channels for visualization
- Adjust the time window and duration of the displayed data
- Real-time updates of the visualization as parameters are changed
- Display voltage traces in millivolts (mV)
- Configurable data source and parameters via config.ini file
Before you begin, ensure you have met the following requirements:
- Python 3.7 or higher installed
- pip (Python package installer)
This project uses data from the CRCNS.org spe-1 dataset, which contains simultaneous patch-clamp and dense CMOS probe extracellular recordings from the same cortical neuron in anesthetized rats. The following files are crucial for understanding and using the data:
-
c45_expt_meta.csv: This file contains metadata about the experiment, specifically the dimensions and data types of the Neuropixel and patch-clamp recordings. The content is:npx,patch "[(384L, 24301033L), 'int16']","[40521060, 'float64']"This indicates that:
- The Neuropixel (npx) data has 384 channels and 24,301,033 samples, stored as 16-bit integers.
- The patch-clamp data has 40,521,060 samples, stored as 64-bit floats.
-
crcns_spe-1_data_description.pdf: This document provides a comprehensive description of the dataset, including:- Summary of the experiment
- Data organization
- File formats
- How to cite the dataset
- Methods used
- Detailed explanation of each file in the dataset
- The dataset includes recordings from 43 neurons in the primary motor and somatosensory cortex of anesthetized rats.
- Data is organized by cell, with each cell having its own directory (cxx, where xx is the cell number).
- The Neuropixel data (
cxx_npx_raw.bin) is stored as a 1D binary file that needs to be reshaped into a 2D array (384 channels x samples). - The conversion factor for Neuropixel data to microvolts is 2.34 μV per bit.
- Patch-clamp data (
cxx_patch_ch1.bin) is already in pA or mV, depending on the recording mode. - Additional files include synchronization channels, spike sample information, and summary data.
Before running the visualization tool, ensure you have:
- Downloaded the necessary data files from CRCNS.org (you may need to request access).
- Placed the
cxx_npx_raw.binfile (where xx is the cell number you're interested in) in the directory specified in yourconfig.inifile. - Updated the
shapeparameter inconfig.inito match the dimensions inc45_expt_meta.csvfor the Neuropixel data.
-
Clone this repository or download the script to your local machine.
-
Navigate to the directory containing the script in your terminal or command prompt.
-
Set up a virtual environment (recommended):
On Windows:
python -m venv venv venv\Scripts\activateOn macOS and Linux:
python3 -m venv venv source venv/bin/activate -
Install the required Python packages by running:
pip install -r requirements.txt -
When you're done working on the project, you can deactivate the virtual environment by running:
deactivate
-
Create a file named
config.iniin the same directory as the script with the following content:[Data] file_path = /path/to/your/neuropixel/data.bin shape = 384,24301033
Replace
/path/to/your/neuropixel/data.binwith the actual path to your Neuropixel recording file. -
Adjust the
shapeparameter to match your data:- The first number is the total number of channels in your Neuropixel probe.
- The second number is the total number of time samples in your recording.
For example, for a 15-minute recording at 30 kHz sampling rate with 384 channels:
shape = 384,27000000(27000000 = 15 minutes * 60 seconds * 30000 samples/second)
-
Open a terminal or command prompt.
-
Navigate to the directory containing the script.
-
Activate the virtual environment if you haven't already:
On Windows:
venv\Scripts\activateOn macOS and Linux:
source venv/bin/activate -
Run the script using Python:
python Neural_Data_Visualization.py -
The application window should appear.
- Enter the channel numbers you want to visualize in the "Channels" field, separated by commas (e.g., "0,50,100,150").
- Click the "Load Data" button to load the specified channels.
- Use the "Center Time" slider or entry field to navigate through the recording.
- Adjust the "Duration" field to change the time window of data displayed.
- Click "Update" or "Update Duration" to refresh the plot with new parameters.
You can customize various aspects of the visualization by modifying the constants at the top of the Neural_Data_Visualization.py file:
DEFAULT_WINDOW_SIZE: Initial size of the application windowDEFAULT_DURATION_SAMPLES: Default number of samples to displayDEFAULT_CHANNELS: Default channels to loadSAMPLING_RATE: Sampling rate of the recording in HzVOLTAGE_CONVERSION_FACTOR: Factor to convert raw values to millivoltsCHANNEL_OFFSET: Vertical offset between channels in the plot
- If you encounter any errors related to missing packages, ensure you've activated the virtual environment and installed all required dependencies using the
requirements.txtfile. - If the data doesn't load, double-check that the file path and shape in
config.inimatch your actual data file. - For any other issues, check the console output for error messages which may provide more information about the problem.
For more detailed information about the dataset and example code for data analysis, visit the companion repository: https://github.com/kampff-lab/sc.io/tree/master/Paired%20Recordings
Contributions to this project are welcome. Please ensure that your code adheres to the existing style and includes appropriate comments and documentation.
This project is licensed under the Apache License, Version 2.0. You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
If you have any questions or feedback, please open an issue in the project repository.
