transform_name='space_denoised_data') # ------------------------------------------------------------------------- # CLEAN DENOISED SPIKESORT (RIGHT AFTER KILOSORT) ------------------------- # To create averages of templates use cmd (because the create_data_cubes doesn't work when called from a REPL): # E:\Software\Develop\Source\Repos\spikesorting_tsne_guis\spikesorting_tsne_guis>python create_data_cubes.py original D:\Data\George\AK_33.1\2018_04_30-11_38\Analysis\Denoised\Kilosort D:\Data\George\AK_33.1\2018_04_30-11_38\Data\Amplifier_APs.bin 1368 50 # To clean: kilosort_folder_denoised = join(denoised_folder, 'Kilosort') clean.cleanup_kilosorted_data(kilosort_folder_denoised, number_of_channels_in_binary_file=const. NUMBER_OF_AP_CHANNELS_IN_BINARY_FILE, binary_data_filename=binary_data_filename, prb_file=const.prb_file, type_of_binary=const.BINARY_FILE_ENCODING, order_of_binary='F', sampling_frequency=20000, num_of_shanks_for_vis=5) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # CREATE TEMPLATE INFO ---------------------------------------------------- spp.generate_probe_positions_of_templates(kilosort_folder_denoised) spp.view_grouped_templates_positions(kilosort_folder_denoised, const.BRAIN_REGIONS, const.PROBE_DIMENSIONS, const.POSITION_MULT) #template_info = preproc_kilo.generate_template_info_after_cleaning(kilosort_folder_denoised, sampling_freq)
# Create once the data cube of the average template spike c_cubes.generate_average_over_spikes_per_template_multiprocess(kilosort_folder, binary_data_filename, const.NUMBER_OF_CHANNELS_IN_BINARY_FILE, cut_time_points_around_spike=100) c_cubes.generate_average_over_spikes_per_template_multiprocess(spyking_circus_folder, binary_data_filename, const.NUMBER_OF_CHANNELS_IN_BINARY_FILE, cut_time_points_around_spike=50) # Run the GUI that helps clean the templates clean.cleanup_kilosorted_data(spyking_circus_folder, number_of_channels_in_binary_file=const.NUMBER_OF_CHANNELS_IN_BINARY_FILE, binary_data_filename=binary_data_filename, prb_file=const.prb_file, type_of_binary=np.float16, order_of_binary='F', sampling_frequency=20000, num_of_shanks_for_vis=5) # ---------------------------------------------------------------- # T-SNE THE CLEANED SPIKES --------------------------------------- # Find how many spikes are clean (demarcated as not noise) templates_of_spikes = np.load(join(kilosort_folder, 'spike_templates.npy')) number_of_raw_spikes = len(templates_of_spikes) template_markings = preproc_kilo.get_template_marking(kilosort_folder) clean_templates = np.argwhere(template_markings > 0) number_of_clean_templates = len(clean_templates) clean_spikes = np.argwhere(np.in1d(templates_of_spikes, clean_templates) > 0)