improves support for raw files
@@ -15,7 +15,9 @@ class MClusSortingExtractor(BaseSorting):
Path to folder with t files.
sampling_frequency : sampling frequency
sampling frequency in Hz.
-
+ raw_to_sec: float or None
+ Required to read files with raw formats. In that case, the samples are saved in the same
+ unit as the input data.
Returns
-------
extractor : MClusSortingExtractor
@@ -25,7 +27,7 @@ class MClusSortingExtractor(BaseSorting):
extractor_name = "MClusSortingExtractor"
installation_mesg = "" # error message when not installed
- def __init__(self, folder_path, sampling_frequency):
+ def __init__(self, folder_path, sampling_frequency, raw_to_sec = None):
end_header_str = '%%ENDHEADER'
ext_list = ['t64', 't32', 't', 'raw64','raw32']
unit_ids = []
@@ -40,6 +42,9 @@ class MClusSortingExtractor(BaseSorting):
if ext is None:
raise Exception("Mclus files not found in path")
+ if ext.startswith('raw') and raw_to_sec is None:
+ raise Exception(f"To load files with extension {ext} a raw_to_sec input is required.")
+
if ext.endswith('64'):
dataformat='>u8'
else:
@@ -58,6 +63,8 @@ class MClusSortingExtractor(BaseSorting):
times = np.fromfile(f,dtype=dataformat)
if ext.startswith('t'):
times = times/10000
+ else:
+ times = times*raw_to_sec
spiketrains[unit] = np.rint(times * sampling_frequency)
@@ -65,7 +72,8 @@ class MClusSortingExtractor(BaseSorting):
BaseSorting.__init__(self, sampling_frequency, unit_ids)
self.add_sorting_segment(MClustSortingSegment(unit_ids, spiketrains))
- self._kwargs = {'folder_path': str(Path(folder_path).absolute()), 'sampling_frequency':sampling_frequency}
+ self._kwargs = {'folder_path': str(Path(folder_path).absolute()), 'sampling_frequency':sampling_frequency,
+ 'raw_to_sec':raw_to_sec}
class MClustSortingSegment(BaseSortingSegment):
