Analyze dataset#
The easiest way to use automea is to set up a csv file with a list of datasets and corresponding wells we want to analyze. The method analyze_dataset() takes as input a csv file and, based on parameters defined by the user, saves different output like statistics for each dataset, a list of spikes and bursts for each well, and more.
As an explample we have prepared the file ‘filenames_and_wells.csv’. Let’s load it with pandas to take a look at it.
import pandas as pd
csv_file = '../automea/final/filenames_and_wells_2.csv'
filenames_and_wells = pd.read_csv(csv_file, sep = ';')
filenames_and_wells
| filename | wells | |
|---|---|---|
| 0 | AH22C001_3039_DIV14.h5 | A6 |
The file contain the dataset named ‘AH22C001_3039_DIV14.h5’, and one well (A6).
import os
os.chdir('../automea/final/')
To perform the analysis we first need to define a set of parameters. Let’s start by importing automea and creating an object from the Analysis() class.
import automea
am = automea.Analysis()
One of the user defined parameters is which model one wants to use to perform the analysis - the machine learning models used for burst detection.
If the user wants to use one of the pretrained models available with the package, it’s only necessary to define the model_name. After this the method loadmodel() can be called, and the chosen model will be used for following analyses.
am.model_name = 'signal30.h5'
am.loadmodel()
We can check the model parameters, used for burst detection, by looking the at model_params attribute.
am.model_params
{'name': 'signal30.h5',
'input_type': 'signal',
'input_average': 30,
'window_size': 50000,
'window_overlap': 25000}
With the model loaded, we can define what we can to save from the analysis, by changing the analysis_params attribute.
am.analysis_params
{'save_spikes': False,
'save_reverbs': False,
'save_bursts': False,
'save_net_reverbs': False,
'save_net_bursts': False,
'save_stats': False}
For instance, if we want to save only the high-level statistics, we set
am.analysis_params['save_stats'] = True
Now, we need to indicate where to find the csv file containing the datasets we want to analyze, the location of the datasets, and define a name for the output files.
am.path_to_csv = ''
csv_file = 'filenames_and_wells_2.csv'
am.path_to_dataset = '../../qneuron/mea-reproduce-results/mea-h5-datafiles/'
am.output_name = 'test'
Finally, we can run the analyze_dataset function for a csv file.
am.analyze_dataset(csv_file)
--- Running full analysis ---
--- Using model signal30.h5 ---
Analyzing dataset: AH22C001_3039_DIV14.h5
Well: A6
--- Done! ---
While the code is running, a message shows which datasets and well are currently being analyzed.
After some minutes - or hours depending on how many datasets we want to analyze - a Done! message is shows indidcating that the process is finished.
The statistics we saved can be found in the file named ‘test_STATS_PREDICTED.csv’. We can import the file and look at the results.
stats = pd.read_csv('test_STATS_PREDICTED.csv')
stats
| Filename | Well Label | Number of channels | Total number of spikes | Mean Firing Rate [Hz] | Stray spikes (%) | Total number of networks bursts | Mean Network Bursting Rate [bursts/minute] | Mean Network Burst Duration [ms] | NIBI | CV of NIBI | Mean reverb per burst | Median of reverb per burst | Mean net reverb per net burst | Median of net reverb per net burst | Total number of network reverb | Mean net reverb frequency [reverb/min] | Mean net reverb duration [ms] | Mean in-reverb freq [Hz] | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | AH22C001_3039_DIV14.h5 | A6 | 12 | 56193 | 7.8 | 11.92 | 49 | 4.9 | 759.41 | 11199.72 | 0.27 | 4.84 | 5.0 | 4.73 | 5.0 | 237 | 23.7 | 91.77 | 189.31 |
The file contains statistics about the dataset/well analyzed.