@@ -1668,11 +1668,13 @@ def generate_test_data(output_path: str):
16681668 """
16691669 Autogenerate the data formats needed for the tutorial pipeline.
16701670
1671- Consists of a single-probe single-segment SpikeGLX recording (both AP and LF bands) as well as Phy spiking data.
1671+ Consists of a single-probe single-segment SpikeGLX recording (both AP and LF bands) as well as Phy sorting data.
16721672 """
16731673 import spikeinterface
1674- from spikeinterface .exporters import export_to_phy
1675- from spikeinterface .preprocessing import bandpass_filter , resample , scale
1674+ import spikeinterface .exporters
1675+ import spikeinterface .preprocessing
1676+
1677+ spikeinterface .set_global_job_kwargs (n_jobs = - 1 )
16761678
16771679 base_path = Path (output_path )
16781680 spikeglx_output_folder = base_path / "spikeglx"
@@ -1687,8 +1689,8 @@ def generate_test_data(output_path: str):
16871689 lf_sampling_frequency = 2_500.0
16881690 downsample_factor = int (ap_sampling_frequency / lf_sampling_frequency )
16891691
1690- # Generate synthetic spiking and voltage traces with waveforms around them
1691- artificial_ap_band_in_uV , spiking = spikeinterface .generate_ground_truth_recording (
1692+ # Generate synthetic sorting and voltage traces with waveforms around them
1693+ artificial_ap_band_in_uV , sorting = spikeinterface .generate_ground_truth_recording (
16921694 durations = [duration_in_s ],
16931695 sampling_frequency = ap_sampling_frequency ,
16941696 num_channels = number_of_channels ,
@@ -1697,12 +1699,18 @@ def generate_test_data(output_path: str):
16971699 seed = 0 , # Fixed seed for reproducibility
16981700 )
16991701
1700- unscaled_artificial_ap_band = scale (recording = artificial_ap_band_in_uV , gain = 1 / conversion_factor_to_uV )
1702+ unscaled_artificial_ap_band = spikeinterface .preprocessing .scale (
1703+ recording = artificial_ap_band_in_uV , gain = 1 / conversion_factor_to_uV
1704+ )
17011705 int16_artificial_ap_band = unscaled_artificial_ap_band .astype (dtype = "int16" )
17021706 int16_artificial_ap_band .set_channel_gains (conversion_factor_to_uV )
17031707
1704- unscaled_artificial_lf_filter = bandpass_filter (recording = unscaled_artificial_ap_band , freq_min = 0.5 , freq_max = 1_000 )
1705- unscaled_artificial_lf_band = resample (recording = unscaled_artificial_lf_filter , resample_rate = 2_500 )
1708+ unscaled_artificial_lf_filter = spikeinterface .preprocessing .bandpass_filter (
1709+ recording = unscaled_artificial_ap_band , freq_min = 0.5 , freq_max = 1_000
1710+ )
1711+ unscaled_artificial_lf_band = spikeinterface .preprocessing .decimate (
1712+ recording = unscaled_artificial_lf_filter , decimation_factor = downsample_factor
1713+ )
17061714 int16_artificial_lf_band = unscaled_artificial_lf_band .astype (dtype = "int16" )
17071715 int16_artificial_lf_band .set_channel_gains (conversion_factor_to_uV )
17081716
@@ -1725,13 +1733,16 @@ def generate_test_data(output_path: str):
17251733 with open (file = lf_meta_file_path , mode = "w" ) as io :
17261734 io .write (lf_meta_content )
17271735
1728- # Make Phy folder
1729- waveform_extractor = spikeinterface .extract_waveforms (
1730- recording = artificial_ap_band_in_uV , sorting = spiking , mode = "memory"
1736+ # Make Phy folder - see https://spikeinterface.readthedocs.io/en/latest/modules/exporters.html
1737+ sorting_analyzer = spikeinterface .create_sorting_analyzer (
1738+ sorting = sorting , recording = artificial_ap_band_in_uV , mode = "memory" , sparse = False
17311739 )
1740+ sorting_analyzer .compute (["random_spikes" , "waveforms" , "templates" , "noise_levels" ])
1741+ sorting_analyzer .compute ("spike_amplitudes" )
1742+ sorting_analyzer .compute ("principal_components" , n_components = 5 , mode = "by_channel_local" )
17321743
1733- export_to_phy (
1734- waveform_extractor = waveform_extractor , output_folder = phy_output_folder , remove_if_exists = True , copy_binary = False
1744+ spikeinterface . exporters . export_to_phy (
1745+ sorting_analyzer = sorting_analyzer , output_folder = phy_output_folder , remove_if_exists = True , copy_binary = False
17351746 )
17361747
17371748
0 commit comments