Skip to content

Commit 957d298

Browse files
committed
Add initial hdsort_compiled.m
1 parent dbf7033 commit 957d298

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

hdsort-compiled/hdsort_compiled.m

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function hdsort_compiled(outputFolder)
2+
try
3+
4+
%% Load sorter configs and params
5+
load(fullfile(outputFolder, 'configsParams.mat'))
6+
7+
if (strcmp(fileFormat, 'maxwell'))
8+
RAW = hdsort.file.MaxWellFile(rawFile);
9+
elseif (strcmp(fileFormat, 'mea1k'))
10+
RAW = hdsort.file.BELMEAFile(rawFile);
11+
end
12+
13+
RAW.restrictToConnectedChannels(); % This line is very important to not sort empty electrodes!
14+
15+
%% Create the object that performs the sorting:
16+
mainFolder = '.';
17+
HDSorting = hdsort.Sorting(RAW, mainFolder, sortingName)
18+
19+
%% Preprocess:
20+
% The preprocessor loads data from the file in chunks, filters it, and saves
21+
% the filtered data into a new hdf5 file that is standardized for all types
22+
% of input data.
23+
% It further performs a couple of operations for each local electrode group
24+
% (LEG) such as spike detection, spike waveform cutting and noise
25+
% estimation. The result is a folder named group000x for each LEG that
26+
% contains the data necessary to perform the parallel parts of the sorting.
27+
% This implementation minimizes the number of time-consuming file access
28+
% operations and thus speeds up the parallel processes significantly, even
29+
% allowing the parallel processes to be run on a small desktop computer or
30+
% laptop.
31+
32+
chunkSize = chunkSize; % This number depends a lot on the available RAM
33+
HDSorting.preprocess('chunkSize', chunkSize, 'forceFileDeletionIfExists', true);
34+
35+
%% Sort each LEG independently:
36+
HDSorting.sort('sortingMode', loopMode); % (default)
37+
% Alternative sorting modes are:
38+
% HDSorting.sort('sortingMode', 'local'); % for loop over each LEG
39+
% HDSorting.sort('sortingMode', 'grid'); % requires a computer grid architecture
40+
41+
%% Combine the results of each LEG in the postprocessing step:
42+
HDSorting.postprocess()
43+
44+
%% Export the results in an easy to read format:
45+
[sortedPopulation, sortedPopulation_discarded] = HDSorting.createSortedPopulation(mainFolder);
46+
47+
%% When the sorting has already been run before, open the results from a file with:
48+
% sortedPopulation = hdsort.results.Population(HDSorting.files.results);
49+
catch
50+
fprintf('----------------------------------------');
51+
fprintf(lasterr());
52+
quit(1);
53+
end
54+
quit(0);
55+
end

0 commit comments

Comments
 (0)