forked from fieldtrip/fileio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_filetype.m
1740 lines (1646 loc) · 78.3 KB
/
ft_filetype.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function [type] = ft_filetype(filename, desired, varargin)
% FT_FILETYPE determines the filetype of many EEG/MEG/MRI data files by
% looking at the name, extension and optionally (part of) its contents.
% It tries to determine the global type of file (which usually
% corresponds to the manufacturer, the recording system or to the
% software used to create the file) and the particular subtype (e.g.
% continuous, average).
%
% Use as
% type = ft_filetype(filename)
% type = ft_filetype(dirname)
%
% This gives you a descriptive string with the data type, and can be
% used in a switch-statement. The descriptive string that is returned
% usually is something like 'XXX_YYY'/ where XXX refers to the
% manufacturer and YYY to the type of the data.
%
% Alternatively, use as
% flag = ft_filetype(filename, type)
% flag = ft_filetype(dirname, type)
% This gives you a boolean flag (0 or 1) indicating whether the file
% is of the desired type, and can be used to check whether the
% user-supplied file is what your subsequent code expects.
%
% Alternatively, use as
% flag = ft_filetype(dirlist, type)
% where the dirlist contains a list of files contained within one
% directory. This gives you a boolean vector indicating for each file
% whether it is of the desired type.
%
% Most filetypes of the following manufacturers and/or software programs are recognized
% - 4D/BTi
% - AFNI
% - ASA
% - Analyse
% - Analyze/SPM
% - BESA
% - Bioimage Suite (*.mgrid)
% - BrainSuite
% - BrainVisa
% - BrainVision
% - Curry
% - Dataq
% - EDF
% - EEProbe
% - Elektra/Neuromag
% - FreeSurfer
% - LORETA
% - Localite
% - MINC
% - Neuralynx
% - Neuroscan
% - Nihon Koden (*.m00)
% - Plexon
% - SR Research Eyelink
% - SensoMotoric Instruments (SMI) *.txt
% - Tobii *.tsv
% - Stanford *.ply
% - Tucker Davis Technology
% - CTF
% - Yokogawa & Ricoh
% - nifti, gifti
% - Nicolet *.e (currently from Natus, formerly Carefusion, Viasys and Taugagreining. Also known as Oxford/Teca/Medelec Valor Nervus)
% - Biopac *.acq
% - AnyWave *.ades
% - Qualisys *.tsv
% - Mrtrix *.mif
% - MAUS *.TextGrid
% - Neurodata Without Borders *.nwb
% - PhysioNet *.hea and *.dat
% - NIRx *.tpl, *.wl1 and *.wl2
% - York Instruments *.meghdf5
% Copyright (C) 2003-2020, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
%
% FieldTrip is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% FieldTrip is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
%
% $Id$
% these are for remembering the type on subsequent calls with the same input arguments
persistent previous_argin previous_argout previous_pwd
if nargin<2
% ensure that all input arguments are defined
desired = [];
end
current_argin = {filename, desired, varargin{:}};
current_pwd = pwd;
if isequal(current_argin, previous_argin) && isequal(current_pwd, previous_pwd)
% don't do the detection again, but return the previous value from cache
type = previous_argout{1};
return
end
if isa(filename, 'memmapfile')
filename = filename.Filename;
end
% % get the optional arguments
% checkheader = ft_getopt(varargin, 'checkheader', true);
%
% if ~checkheader
% % assume that the header is always ok, e.g when the file does not yet exist
% % this replaces the normal function with a function that always returns true
% filetype_check_header = @filetype_true;
% end
if iscell(filename)
if ~isempty(desired)
% perform the test for each filename, return a boolean vector
type = false(size(filename));
else
% return a string with the type for each filename
type = cell(size(filename));
end
for i=1:length(filename)
if strcmp(filename{i}(end), '.')
% do not recurse into this directory or the parent directory
continue
else
if iscell(type)
type{i} = ft_filetype(filename{i}, desired);
else
type(i) = ft_filetype(filename{i}, desired);
end
end
end
return
end
% start with unknown values
type = 'unknown';
manufacturer = 'unknown';
content = 'unknown';
if isempty(filename)
if isempty(desired)
% return the "unknown" outputs
return
else
% return that it is a non-match
type = false;
return
end
end
% the parts of the filename are used further down
if isfolder(filename)
[p, f, x] = fileparts(filename);
p = filename; % the full path to the directory name
d = f; % the last part of the directory name
f = '';
x = '';
else
[p, f, x] = fileparts(filename);
end
% prevent this test if the filename resembles an URI, i.e. like "scheme://"
if ~contains(filename , '://') && isfolder(filename)
% the directory listing is needed below
ls = dir(filename);
% remove the parent directory and the directory itself from the list
ls = ls(~strcmp({ls.name}, '.'));
ls = ls(~strcmp({ls.name}, '..'));
for i=1:length(ls)
% make sure that the directory listing includes the complete path
ls(i).name = fullfile(filename, ls(i).name);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% start determining the filetype
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this checks for a compressed file (of arbitrary type)
if filetype_check_extension(filename, 'zip')...
|| (filetype_check_extension(filename, '.gz') && ~filetype_check_extension(filename, '.nii.gz'))...
|| filetype_check_extension(filename, 'tgz')...
|| filetype_check_extension(filename, 'tar')
type = 'compressed';
manufacturer = 'undefined';
content = 'unknown, extract first';
% these are some streams for asynchronous BCI
elseif filetype_check_uri(filename, 'fifo')
type = 'fcdc_fifo';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'stream';
elseif filetype_check_uri(filename, 'buffer')
type = 'fcdc_buffer';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'stream';
elseif filetype_check_uri(filename, 'mysql')
type = 'fcdc_mysql';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'stream';
elseif filetype_check_uri(filename, 'tcp')
type = 'fcdc_tcp';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'stream';
elseif filetype_check_uri(filename, 'udp')
type = 'fcdc_udp';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'stream';
elseif filetype_check_uri(filename, 'rfb')
type = 'fcdc_rfb';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'stream';
elseif filetype_check_uri(filename, 'serial')
type = 'fcdc_serial';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'stream';
elseif filetype_check_uri(filename, 'global')
type = 'fcdc_global';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'global variable';
elseif filetype_check_uri(filename, 'shm')
type = 'ctf_shm';
manufacturer = 'CTF';
content = 'real-time shared memory buffer';
elseif filetype_check_uri(filename, 'empty')
type = 'empty';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = '/dev/null';
% known CTF file types
elseif isfolder(filename) && filetype_check_extension(filename, '.ds') && exist(fullfile(filename, [f '.res4']), 'file')
type = 'ctf_ds';
manufacturer = 'CTF';
content = 'MEG dataset';
elseif isfolder(filename) && ~isempty(dir(fullfile(filename, '*.res4'))) && ~isempty(dir(fullfile(filename, '*.meg4')))
type = 'ctf_ds';
manufacturer = 'CTF';
content = 'MEG dataset';
elseif filetype_check_extension(filename, '.res4') && (filetype_check_header(filename, 'MEG41RS') || filetype_check_header(filename, 'MEG42RS') || filetype_check_header(filename, 'MEG4RES') || filetype_check_header(filename, 'MEG3RES')) %'MEG3RES' pertains to ctf64.ds
type = 'ctf_res4';
manufacturer = 'CTF';
content = 'MEG/EEG header information';
elseif filetype_check_extension(filename, '.meg4') && (filetype_check_header(filename, 'MEG41CP') || filetype_check_header(filename, 'MEG4CPT')) %'MEG4CPT' pertains to ctf64.ds
type = 'ctf_meg4';
manufacturer = 'CTF';
content = 'MEG/EEG';
elseif strcmp(f, 'MarkerFile') && filetype_check_extension(filename, '.mrk') && filetype_check_header(filename, 'PATH OF DATASET:')
type = 'ctf_mrk';
manufacturer = 'CTF';
content = 'marker file';
elseif filetype_check_extension(filename, '.mri') && filetype_check_header(filename, 'CTF_MRI_FORMAT VER 2.2')
type = 'ctf_mri';
manufacturer = 'CTF';
content = 'MRI';
elseif filetype_check_extension(filename, '.mri') && filetype_check_header(filename, 'CTF_MRI_FORMAT VER 4', 31)
type = 'ctf_mri4';
manufacturer = 'CTF';
content = 'MRI';
elseif filetype_check_extension(filename, '.hdm')
type = 'ctf_hdm';
manufacturer = 'CTF';
content = 'volume conduction model';
elseif filetype_check_extension(filename, '.hc')
type = 'ctf_hc';
manufacturer = 'CTF';
content = 'headcoil locations';
elseif filetype_check_extension(filename, '.shape')
type = 'ctf_shape';
manufacturer = 'CTF';
content = 'headshape points';
elseif filetype_check_extension(filename, '.shape_info')
type = 'ctf_shapeinfo';
manufacturer = 'CTF';
content = 'headshape information';
elseif filetype_check_extension(filename, '.wts')
type = 'ctf_wts';
manufacturer = 'CTF';
content = 'SAM coefficients, i.e. spatial filter weights';
elseif filetype_check_extension(filename, '.svl')
type = 'ctf_svl';
manufacturer = 'CTF';
content = 'SAM (pseudo-)statistic volumes';
% known Micromed file types
elseif filetype_check_extension(filename, '.trc') && filetype_check_header(filename, '* MICROMED')
type = 'micromed_trc';
manufacturer = 'Micromed';
content = 'Electrophysiological data';
% known Neuromag file types
elseif filetype_check_extension(filename, '.fif')
type = 'neuromag_fif';
manufacturer = 'Neuromag';
content = 'MEG header and data';
elseif filetype_check_extension(filename, '.mesh')
type = 'neuromag_mesh';
manufacturer = 'Neuromag';
content = 'triangulated surface mesh';
elseif filetype_check_extension(filename, '.bdip')
type = 'neuromag_bdip';
manufacturer = 'Neuromag';
content = 'dipole model';
elseif filetype_check_extension(filename, '.eve') && exist(fullfile(p, [f '.fif']), 'file')
type = 'neuromag_eve'; % these are being used by Tristan Technologies for the BabySQUID system
manufacturer = 'Neuromag';
content = 'events';
elseif filetype_check_extension(filename, '.log') && filetype_check_header(filename, '*** This is Elekta Neuromag MaxFilter', 61)
type = 'neuromag_maxfilterlog';
manufacturer = 'Neuromag';
content = 'MaxFilter log information';
elseif filetype_check_extension(filename, '.pos') && filetype_check_header(filename, ' Time q1 ', 0)
type = 'neuromag_headpos';
manufacturer = 'Neuromag';
content = 'MaxFilter head position information';
elseif filetype_check_extension(filename, '.iso') && filetype_check_header(filename, char([0 0 0 100]))
type = 'neuromag_iso';
manufacturer = 'Neuromag';
content = 'Isotrack digitizer points';
elseif strcmp(filename, 'sss_cal.dat')
type = 'neuromag_cal';
manufacturer = 'Neuromag';
content = 'Fine calibration';
% known Yokogawa & Ricoh file types
elseif filetype_check_extension(filename, '.ave') || filetype_check_extension(filename, '.sqd')
if ~isricohmegfile(filename)
type = 'yokogawa_ave';
manufacturer = 'Yokogawa';
content = 'averaged MEG data';
else
type = 'ricoh_ave';
manufacturer = 'Ricoh';
content = 'averaged MEG data';
end
elseif filetype_check_extension(filename, '.con')
if ~isricohmegfile(filename)
type = 'yokogawa_con';
manufacturer = 'Yokogawa';
content = 'continuous MEG data';
else
type = 'ricoh_con';
manufacturer = 'Ricoh';
content = 'continuous MEG data';
end
elseif filetype_check_extension(filename, '.raw') && filetype_check_header(filename, char([0 0 0 0])) % FIXME, this detection should possibly be improved
type = 'yokogawa_raw';
manufacturer = 'Yokogawa';
content = 'evoked/trialbased MEG data';
elseif filetype_check_extension(filename, '.mrk') && filetype_check_header(filename, char([0 0 0 0])) % FIXME, this detection should possibly be improved
if ~isricohmegfile(filename)
type = 'yokogawa_mrk';
manufacturer = 'Yokogawa';
content = 'headcoil locations';
else
type = 'ricoh_mrk';
manufacturer = 'Ricoh';
content = 'headcoil locations';
end
elseif filetype_check_extension(filename, '.txt') && numel(strfind(filename,'-coregis')) == 1
type = 'yokogawa_coregis';
manufacturer = 'Yokogawa';
content = 'exported fiducials';
elseif filetype_check_extension(filename, '.txt') && numel(strfind(filename,'-calib')) == 1
type = 'yokogawa_calib';
manufacturer = 'Yokogawa';
elseif filetype_check_extension(filename, '.txt') && numel(strfind(filename,'-channel')) == 1
type = 'yokogawa_channel';
manufacturer = 'Yokogawa';
elseif filetype_check_extension(filename, '.txt') && numel(strfind(filename,'-property')) == 1
type = 'yokogawa_property';
manufacturer = 'Yokogawa';
elseif filetype_check_extension(filename, '.txt') && numel(strfind(filename,'-TextData')) == 1
type = 'yokogawa_textdata';
manufacturer = 'Yokogawa';
elseif filetype_check_extension(filename, '.txt') && numel(strfind(filename,'-FLL')) == 1
type = 'yokogawa_fll';
manufacturer = 'Yokogawa';
elseif filetype_check_extension(filename, '.hsp')
type = 'yokogawa_hsp';
manufacturer = 'Yokogawa';
% Neurosim files; this has to go before the 4D detection
elseif ~isfolder(filename) && (strcmp(f,'spikes') || filetype_check_header(filename,'# Spike information'))
type = 'neurosim_spikes';
manufacturer = 'Jan van der Eerden (DCCN)';
content = 'simulated spikes';
elseif ~isfolder(filename) && (strcmp(f,'evolution') || filetype_check_header(filename,'# Voltages'))
type = 'neurosim_evolution';
manufacturer = 'Jan van der Eerden (DCCN)';
content = 'simulated membrane voltages and currents';
elseif ~isfolder(filename) && (strcmp(f,'signals') || filetype_check_header(filename,'# Internal',2))
type = 'neurosim_signals';
manufacturer = 'Jan van der Eerden (DCCN)';
content = 'simulated network signals';
elseif isfolder(filename) && exist(fullfile(filename, 'signals'), 'file') && exist(fullfile(filename, 'spikes'), 'file')
type = 'neurosim_ds';
manufacturer = 'Jan van der Eerden (DCCN)';
content = 'simulated spikes and continuous signals';
% known 4D/BTI file types
elseif filetype_check_extension(filename, '.pdf') && filetype_check_header(filename, 'E|lk') % I am not sure whether this header always applies
type = '4d_pdf';
manufacturer = '4D/BTI';
content = 'raw MEG data (processed data file)';
elseif exist([filename '.m4d'], 'file') && exist([filename '.xyz'], 'file') % these two ascii header files accompany the raw data
type = '4d_pdf';
manufacturer = '4D/BTI';
content = 'raw MEG data (processed data file)';
elseif filetype_check_extension(filename, '.m4d') && exist([filename(1:(end-3)) 'xyz'], 'file') % these come in pairs
type = '4d_m4d';
manufacturer = '4D/BTI';
content = 'MEG header information';
elseif filetype_check_extension(filename, '.xyz') && exist([filename(1:(end-3)) 'm4d'], 'file') % these come in pairs
type = '4d_xyz';
manufacturer = '4D/BTI';
content = 'MEG sensor positions';
elseif isequal(f, 'hs_file') % the filename is "hs_file"
type = '4d_hs';
manufacturer = '4D/BTI';
content = 'head shape';
elseif length(filename)>=4 && contains(filename,',rf')
type = '4d';
manufacturer = '4D/BTi';
content = '';
elseif filetype_check_extension(filename, '.el.ascii') && filetype_check_ascii(filename, 20) % assume that there are at least 20 bytes in the file, the example one has 4277 bytes
type = '4d_el_ascii';
manufacturer = '4D/BTi';
content = 'electrode positions';
% known EEProbe file types
elseif filetype_check_extension(filename, '.cnt') && (filetype_check_header(filename, 'RIFF') || filetype_check_header(filename, 'RF64'))
type = 'eep_cnt';
manufacturer = 'EEProbe';
content = 'EEG';
elseif filetype_check_extension(filename, '.avr') && filetype_check_header(filename, char([38 0 16 0]))
type = 'eep_avr';
manufacturer = 'EEProbe';
content = 'ERP';
elseif filetype_check_extension(filename, '.trg')
type = 'eep_trg';
manufacturer = 'EEProbe';
content = 'trigger information';
elseif filetype_check_extension(filename, '.rej')
type = 'eep_rej';
manufacturer = 'EEProbe';
content = 'rejection marks';
% the yokogawa_mri has to be checked prior to asa_mri, because this one is more strict
elseif filetype_check_extension(filename, '.mri') && filetype_check_header(filename, char(0)) % FIXME, this detection should possibly be improved
type = 'yokogawa_mri';
manufacturer = 'Yokogawa';
content = 'anatomical MRI';
% known ASA file types
elseif filetype_check_extension(filename, '.elc')
type = 'asa_elc';
manufacturer = 'ASA';
content = 'electrode positions';
elseif filetype_check_extension(filename, '.vol')
type = 'asa_vol';
manufacturer = 'ASA';
content = 'volume conduction model';
elseif filetype_check_extension(filename, '.bnd')
type = 'asa_bnd';
manufacturer = 'ASA';
content = 'boundary element model details';
elseif filetype_check_extension(filename, '.msm')
type = 'asa_msm';
manufacturer = 'ASA';
content = 'ERP';
elseif filetype_check_extension(filename, '.msr')
type = 'asa_msr';
manufacturer = 'ASA';
content = 'ERP';
elseif filetype_check_extension(filename, '.dip')
% FIXME, can also be CTF dipole file
type = 'asa_dip';
manufacturer = 'ASA';
elseif filetype_check_extension(filename, '.mri')
% FIXME, can also be CTF mri file
type = 'asa_mri';
manufacturer = 'ASA';
content = 'MRI image header';
elseif filetype_check_extension(filename, '.iso') && ~filetype_check_header(filename, char([0 0 0 100]))
type = 'asa_iso';
manufacturer = 'ASA';
content = 'MRI image data';
% known BCI2000 file types
elseif filetype_check_extension(filename, '.dat') && (filetype_check_header(filename, 'BCI2000') || filetype_check_header(filename, 'HeaderLen='))
type = 'bci2000_dat';
manufacturer = 'BCI2000';
content = 'continuous EEG';
% known Neuroscan file types
elseif filetype_check_extension(filename, '.avg') && filetype_check_header(filename, 'Version 3.0')
type = 'ns_avg';
manufacturer = 'Neuroscan';
content = 'averaged EEG';
elseif filetype_check_extension(filename, '.cnt') && filetype_check_header(filename, 'Version 3.0')
type = 'ns_cnt';
manufacturer = 'Neuroscan';
content = 'continuous EEG';
elseif filetype_check_extension(filename, '.eeg') && filetype_check_header(filename, 'Version 3.0')
type = 'ns_eeg';
manufacturer = 'Neuroscan';
content = 'epoched EEG';
elseif filetype_check_extension(filename, '.eeg') && filetype_check_header(filename, 'V3.0')
type = 'neuroprax_eeg';
manufacturer = 'eldith GmbH';
content = 'continuous EEG';
elseif filetype_check_extension(filename, '.ee_')
type = 'neuroprax_mrk';
manufacturer = 'eldith GmbH';
content = 'EEG markers';
% known Analyze & SPM file types
elseif filetype_check_extension(filename, '.hdr')
type = 'analyze_hdr';
manufacturer = 'Mayo Analyze';
content = 'PET/MRI image header';
elseif filetype_check_extension(filename, '.img')
type = 'analyze_img';
manufacturer = 'Mayo Analyze';
content = 'PET/MRI image data';
elseif filetype_check_extension(filename, '.mnc')
type = 'minc';
content = 'MRI image data';
elseif filetype_check_extension(filename, '.nii') && filetype_check_header(filename, {[92 1 0 0], [0 0 1 92]}) % header starts with the number 348
type = 'nifti';
content = 'MRI image data';
elseif filetype_check_extension(filename, '.nii') && filetype_check_header(filename, {[28 2 0 0], [0 0 2 28]}) % header starts with the number 540
type = 'nifti2';
content = 'MRI image data';
% known FSL file types
elseif filetype_check_extension(filename, '.nii.gz')
type = 'nifti_gz';
content = 'MRI image data';
% known LORETA file types
elseif filetype_check_extension(filename, '.lorb')
type = 'loreta_lorb';
manufacturer = 'old LORETA';
content = 'source reconstruction';
elseif filetype_check_extension(filename, '.slor')
type = 'loreta_slor';
manufacturer = 'sLORETA';
content = 'source reconstruction';
% known AFNI file types
elseif filetype_check_extension(lower(filename), '.brik')
type = 'afni_brik';
content = 'MRI image data';
elseif filetype_check_extension(lower(filename), '.head')
type = 'afni_head';
content = 'MRI header data';
% known BrainVison file types
elseif filetype_check_extension(filename, '.vhdr')
type = 'brainvision_vhdr';
manufacturer = 'BrainProducts';
content = 'EEG header';
elseif filetype_check_extension(filename, '.vmrk')
type = 'brainvision_vmrk';
manufacturer = 'BrainProducts';
content = 'EEG markers';
elseif filetype_check_extension(filename, '.vabs')
type = 'brainvision_vabs';
manufacturer = 'BrainProducts';
content = 'Brain Vison Analyzer macro';
elseif filetype_check_extension(filename, '.eeg') && exist(fullfile(p, [f '.vhdr']), 'file')
type = 'brainvision_eeg';
manufacturer = 'BrainProducts';
content = 'continuous EEG data';
elseif filetype_check_extension(filename, '.seg')
type = 'brainvision_seg';
manufacturer = 'BrainProducts';
content = 'segmented EEG data';
elseif filetype_check_extension(filename, '.dat') && exist(fullfile(p, [f '.vhdr']), 'file') &&...
~filetype_check_header(filename, 'HeaderLen=') && ~filetype_check_header(filename, 'BESA_SA_IMAGE') &&...
~(exist(fullfile(p, [f '.gen']), 'file') || exist(fullfile(p, [f '.generic']), 'file'))
% WARNING this is a very general name, it could be exported BrainVision
% data but also a BESA beamformer source reconstruction or BCI2000
type = 'brainvision_dat';
manufacturer = 'BrainProducts';
content = 'exported EEG data';
elseif filetype_check_extension(filename, '.marker')
type = 'brainvision_marker';
manufacturer = 'BrainProducts';
content = 'rejection markers';
% known Polhemus file types
elseif filetype_check_extension(filename, '.pos')
type = 'polhemus_pos';
manufacturer = 'BrainProducts/CTF/Polhemus?'; % actually I don't know whose software it is
content = 'electrode positions';
% known Blackrock Microsystems file types
elseif strncmp(x,'.ns',3) && (filetype_check_header(filename, 'NEURALCD') || filetype_check_header(filename, 'NEURALSG'))
type = 'blackrock_nsx';
manufacturer = 'Blackrock Microsystems';
content = 'conintuously sampled data';
elseif filetype_check_extension(filename, '.nev') && filetype_check_header(filename, 'NEURALEV')
type = 'blackrock_nev';
manufacturer = 'Blackrock Microsystems';
contenct = 'extracellular electrode spike information';
% known Neuralynx file types
elseif filetype_check_extension(filename, '.nev') || filetype_check_extension(filename, '.Nev')
type = 'neuralynx_nev';
manufacturer = 'Neuralynx';
content = 'event information';
elseif filetype_check_extension(filename, '.ncs') && filetype_check_header(filename, '####')
type = 'neuralynx_ncs';
manufacturer = 'Neuralynx';
content = 'continuous single channel recordings';
elseif filetype_check_extension(filename, '.nse') && filetype_check_header(filename, '####')
type = 'neuralynx_nse';
manufacturer = 'Neuralynx';
content = 'spike waveforms';
elseif filetype_check_extension(filename, '.nts') && filetype_check_header(filename, '####')
type = 'neuralynx_nts';
manufacturer = 'Neuralynx';
content = 'timestamps only';
elseif filetype_check_extension(filename, '.nvt')
type = 'neuralynx_nvt';
manufacturer = 'Neuralynx';
content = 'video tracker';
elseif filetype_check_extension(filename, '.nst')
type = 'neuralynx_nst';
manufacturer = 'Neuralynx';
content = 'continuous stereotrode recordings';
elseif filetype_check_extension(filename, '.ntt')
type = 'neuralynx_ntt';
manufacturer = 'Neuralynx';
content = 'continuous tetrode recordings';
elseif strcmpi(f, 'logfile') && strcmpi(x, '.txt') % case insensitive
type = 'neuralynx_log';
manufacturer = 'Neuralynx';
content = 'log information in ASCII format';
elseif contains(lower(f), 'dma') && strcmpi(x, '.log') % this is not a very strong detection
type = 'neuralynx_dma';
manufacturer = 'Neuralynx';
content = 'raw aplifier data directly from DMA';
elseif filetype_check_extension(filename, '.nrd') % see also above, since Cheetah 5.x the file extension has changed
type = 'neuralynx_dma';
manufacturer = 'Neuralynx';
content = 'raw aplifier data directly from DMA';
elseif isfolder(filename) && (any(filetype_check_extension({ls.name}, '.nev')) || any(filetype_check_extension({ls.name}, '.Nev')))
% a regular Neuralynx dataset directory that contains an event file
type = 'neuralynx_ds';
manufacturer = 'Neuralynx';
content = 'dataset';
elseif isfolder(filename) && most(filetype_check_extension({ls.name}, '.ncs'))
% a directory containing continuously sampled channels in Neuralynx format
type = 'neuralynx_ds';
manufacturer = 'Neuralynx';
content = 'continuously sampled channels';
elseif isfolder(filename) && most(filetype_check_extension({ls.name}, '.nse'))
% a directory containing spike waveforms in Neuralynx format
type = 'neuralynx_ds';
manufacturer = 'Neuralynx';
content = 'spike waveforms';
elseif isfolder(filename) && most(filetype_check_extension({ls.name}, '.nte'))
% a directory containing spike timestamps in Neuralynx format
type = 'neuralynx_ds';
manufacturer = 'Neuralynx';
content = 'spike timestamps';
elseif isfolder(filename) && most(filetype_check_extension({ls.name}, '.ntt'))
% a directory containing tetrode recordings in Neuralynx format
type = 'neuralynx_ds';
manufacturer = 'Neuralynx';
content = 'tetrode recordings ';
elseif filetype_check_extension(filename, '.mat') && contains(filename, 'times_')
type = 'wave_clus';
manufacturer = 'Department of Engineering, University of Leicester, UK';
content = 'sorted spikes';
elseif isfolder(p) && exist(fullfile(p, 'header'), 'file') && exist(fullfile(p, 'samples'), 'file') && exist(fullfile(p, 'events'), 'file')
type = 'fcdc_buffer_offline';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'FieldTrip buffer offline dataset';
elseif isfolder(filename) && exist(fullfile(filename, 'info.xml'), 'file') && exist(fullfile(filename, 'signal1.bin'), 'file')
% this is an OS X package directory representing a complete EEG dataset
% it contains a Content file, multiple xml files and one or more signalN.bin files
type = 'egi_mff';
manufacturer = 'Electrical Geodesics Incorporated';
content = 'raw EEG data';
elseif ~isfolder(filename) && isfolder(p) && exist(fullfile(p, 'info.xml'), 'file') && exist(fullfile(p, 'signal1.bin'), 'file')
% the file that the user specified is one of the files in an mff package directory
type = 'egi_mff';
manufacturer = 'Electrical Geodesics Incorporated';
content = 'raw EEG data';
% these are formally not Neuralynx file formats, but at the FCDC we use them together with Neuralynx
elseif isfolder(filename) && filetype_check_neuralynx_cds(filename)
% a downsampled Neuralynx DMA file can be split into three separate lfp/mua/spike directories
% treat them as one combined dataset
type = 'neuralynx_cds';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'dataset containing separate lfp/mua/spike directories';
elseif filetype_check_extension(filename, '.tsl') && filetype_check_header(filename, 'tsl')
type = 'neuralynx_tsl';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'timestamps from DMA log file';
elseif filetype_check_extension(filename, '.tsh') && filetype_check_header(filename, 'tsh')
type = 'neuralynx_tsh';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'timestamps from DMA log file';
elseif filetype_check_extension(filename, '.ttl') && filetype_check_header(filename, 'ttl')
type = 'neuralynx_ttl';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'Parallel_in from DMA log file';
elseif filetype_check_extension(filename, '.bin') && filetype_check_header(filename, {'uint8', 'uint16', 'uint32', 'int8', 'int16', 'int32', 'int64', 'float32', 'float64'})
type = 'neuralynx_bin';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'single channel continuous data';
elseif isfolder(filename) && any(filetype_check_extension({ls.name}, '.ttl')) && any(filetype_check_extension({ls.name}, '.tsl')) && any(filetype_check_extension({ls.name}, '.tsh'))
% a directory containing the split channels from a DMA logfile
type = 'neuralynx_sdma';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'split DMA log file';
elseif isfolder(filename) && filetype_check_extension(filename, '.sdma')
% a directory containing the split channels from a DMA logfile
type = 'neuralynx_sdma';
manufacturer = 'Donders Centre for Cognitive Neuroimaging';
content = 'split DMA log file';
% known Plexon file types
elseif filetype_check_extension(filename, '.nex') && filetype_check_header(filename, 'NEX1')
type = 'plexon_nex';
manufacturer = 'Plexon';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.plx') && filetype_check_header(filename, 'PLEX')
type = 'plexon_plx';
manufacturer = 'Plexon';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.ddt')
type = 'plexon_ddt';
manufacturer = 'Plexon';
elseif isfolder(filename) && most(filetype_check_extension({ls.name}, '.nex')) && most(filetype_check_header({ls.name}, 'NEX1'))
% a directory containing multiple plexon NEX files
type = 'plexon_ds';
manufacturer = 'Plexon';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.nex5') && filetype_check_header(filename, 'NEX5')
type = 'plexon_nex5';
manufacturer = 'Nex Technologies';
content = 'electrophysiological data';
% known Cambridge Electronic Design file types
elseif filetype_check_extension(filename, '.smr')
type = 'ced_son';
manufacturer = 'Cambridge Electronic Design';
content = 'Spike2 SON filing system';
% known BESA file types
elseif filetype_check_extension(filename, '.avr') && strcmp(type, 'unknown')
type = 'besa_avr'; % FIXME, can also be EEProbe average EEG
manufacturer = 'BESA';
content = 'average EEG';
elseif filetype_check_extension(filename, '.elp')
type = 'besa_elp';
manufacturer = 'BESA';
content = 'electrode positions';
elseif filetype_check_extension(filename, '.eps')
type = 'besa_eps';
manufacturer = 'BESA';
content = 'digitizer information';
elseif filetype_check_extension(filename, '.sfp')
type = 'besa_sfp';
manufacturer = 'BESA';
content = 'sensor positions';
elseif filetype_check_extension(filename, '.ela')
type = 'besa_ela';
manufacturer = 'BESA';
content = 'sensor information';
elseif filetype_check_extension(filename, '.pdg')
type = 'besa_pdg';
manufacturer = 'BESA';
content = 'paradigm file';
elseif filetype_check_extension(filename, '.tfc')
type = 'besa_tfc';
manufacturer = 'BESA';
content = 'time frequency coherence';
elseif filetype_check_extension(filename, '.mul')
type = 'besa_mul';
manufacturer = 'BESA';
content = 'multiplexed ascii format';
elseif filetype_check_extension(filename, '.dat') && filetype_check_header(filename, 'BESA_SA') % header can start with BESA_SA_IMAGE or BESA_SA_MN_IMAGE
type = 'besa_src';
manufacturer = 'BESA';
content = 'beamformer source reconstruction';
elseif filetype_check_extension(filename, '.swf') && filetype_check_header(filename, 'Npts=')
type = 'besa_swf';
manufacturer = 'BESA';
content = 'beamformer source waveform';
elseif filetype_check_extension(filename, '.bsa')
type = 'besa_bsa';
manufacturer = 'BESA';
content = 'beamformer source locations and orientations';
elseif exist(fullfile(p, [f '.dat']), 'file') && (exist(fullfile(p, [f '.gen']), 'file') || exist(fullfile(p, [f '.generic']), 'file'))
type = 'besa_sb';
manufacturer = 'BESA';
content = 'simple binary channel data with a separate generic ascii header';
elseif filetype_check_extension(filename, '.sfh') && filetype_check_header(filename, 'NrOfPoints')
type = 'besa_sfh';
manufacturer = 'BESA';
content = 'electrode and fiducial information';
elseif filetype_check_extension(filename, '.besa')
type = 'besa_besa';
manufacturer = 'BESA';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.srf') && filetype_check_header(filename, [0 0 0 0], 4)
type = 'brainvoyager_srf';
manufacturer = 'BrainVoyager'; % see http://support.brainvoyager.com/installation-introduction/23-file-formats/375-users-guide-23-the-format-of-srf-files.html
content = 'surface';
% known Dataq file formats
elseif filetype_check_extension(upper(filename), '.WDQ')
type = 'dataq_wdq';
manufacturer = 'dataq instruments';
content = 'electrophysiological data';
% old files from Pascal Fries' PhD research at the MPI
elseif filetype_check_extension(filename, '.dap') && filetype_check_header(filename, char(1))
type = 'mpi_dap';
manufacturer = 'MPI Frankfurt';
content = 'electrophysiological data';
elseif isfolder(filename) && ~isempty(cell2mat(regexp({ls.name}, '.dap$')))
type = 'mpi_ds';
manufacturer = 'MPI Frankfurt';
content = 'electrophysiological data';
% Frankfurt SPASS format, which uses the Labview Datalog (DTLG) format
elseif filetype_check_extension(filename, '.ana') && filetype_check_header(filename, 'DTLG')
type = 'spass_ana';
manufacturer = 'MPI Frankfurt';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.swa') && filetype_check_header(filename, 'DTLG')
type = 'spass_swa';
manufacturer = 'MPI Frankfurt';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.spi') && filetype_check_header(filename, 'DTLG')
type = 'spass_spi';
manufacturer = 'MPI Frankfurt';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.stm') && filetype_check_header(filename, 'DTLG')
type = 'spass_stm';
manufacturer = 'MPI Frankfurt';
content = 'electrophysiological data';
elseif filetype_check_extension(filename, '.bhv') && filetype_check_header(filename, 'DTLG')
type = 'spass_bhv';
manufacturer = 'MPI Frankfurt';
content = 'electrophysiological data';
% known Chieti ITAB file types
elseif filetype_check_extension(filename, '.raw') && (filetype_check_header(filename, 'FORMAT: ATB-BIOMAGDATA') || filetype_check_header(filename, '[HeaderType]'))
type = 'itab_raw';
manufacturer = 'Chieti ITAB';
content = 'MEG data, including sensor positions';
elseif filetype_check_extension(filename, '.raw.mhd')
type = 'itab_mhd';
manufacturer = 'Chieti ITAB';
content = 'MEG header data, including sensor positions';
elseif filetype_check_extension(filename, '.asc') && ~filetype_check_header(filename, '**')
type = 'itab_asc';
manufacturer = 'Chieti ITAB';
content = 'headshape digitization file';
% known Nexstim file types
elseif filetype_check_extension(filename, '.nxe')
type = 'nexstim_nxe';
manufacturer = 'Nexstim';
content = 'electrophysiological data';
% known Tucker-Davis-Technology file types
elseif filetype_check_extension(filename, '.tbk')
type = 'tdt_tbk';
manufacturer = 'Tucker-Davis-Technology';
content = 'database/tank meta-information';
elseif filetype_check_extension(filename, '.tdx')
type = 'tdt_tdx';
manufacturer = 'Tucker-Davis-Technology';
content = 'database/tank meta-information';
elseif filetype_check_extension(filename, '.tsq')
type = 'tdt_tsq';
manufacturer = 'Tucker-Davis-Technology';
content = 'block header information';
elseif filetype_check_extension(filename, '.tev')
type = 'tdt_tev';
manufacturer = 'Tucker-Davis-Technology';
content = 'electrophysiological data';
% raw audio and video data from https://github.com/andreyzhd/VideoMEG
% the extension *.aud/*.vid is used at NatMEG and *.audio.dat/*.video.dat seems to be used in Helsinki
elseif (filetype_check_extension(filename, '.aud') || filetype_check_extension(filename, '.audio.dat')) && filetype_check_header(filename, 'ELEKTA_AUDIO_FILE')
% this should go before curry_dat
type = 'videomeg_aud';
manufacturer = 'VideoMEG';
content = 'audio';
elseif (filetype_check_extension(filename, '.vid') || filetype_check_extension(filename, '.video.dat')) && filetype_check_header(filename, 'ELEKTA_VIDEO_FILE')
% this should go before curry_dat
type = 'videomeg_vid';
manufacturer = 'VideoMEG';
content = 'video';
elseif (filetype_check_extension(filename, '.avi') || filetype_check_extension(filename, '.vlf') || filetype_check_extension(filename, '.wmv') || filetype_check_extension(filename, '.mov') || filetype_check_extension(filename, '.mp4'))
% generic fideo files, these are also supported by ft_read_header and ft_read_data
type = 'video';
manufacturer = 'generic';
content = 'video';
elseif (filetype_check_extension(filename, '.dat') || filetype_check_extension(filename, '.Dat')) && (exist(fullfile(p, [f '.ini']), 'file') || exist(fullfile(p, [f '.Ini']), 'file'))
% this should go before curry_dat
type = 'deymed_dat';
manufacturer = 'Deymed';
content = 'raw eeg data';
elseif (filetype_check_extension(filename, '.ini') || filetype_check_extension(filename, '.Ini')) && (exist(fullfile(p, [f '.dat']), 'file') || exist(fullfile(p, [f '.Dat']), 'file'))
type = 'deymed_ini';
manufacturer = 'Deymed';
content = 'eeg header information';
elseif filetype_check_extension(filename, '.dat') && (filetype_check_header(filename, [0 0 16 0 16 0], 8) || filetype_check_header(filename, [0 0 16 0 16 0], 0))
% this should go before curry_dat
type = 'jaga16';
manufacturer = 'Jinga-Hi';
content = 'electrophysiological data';
% some AnyWave file formats, see http://meg.univ-amu.fr/wiki/AnyWave:ADES
elseif filetype_check_extension(filename, '.ades') && filetype_check_header(filename, '#ADES') && exist(fullfile(p, [f '.dat']), 'file')
type = 'anywave_ades';
manufacturer = 'AnyWave';
content = 'continuous EEG, iEEG or MEG data';
elseif filetype_check_extension(filename, '.dat') && exist(fullfile(p, [f '.ades']), 'file') && filetype_check_header(fullfile(p, [f '.ades']), '#ADES')
% this should go before curry_dat
type = 'anywave_dat';
manufacturer = 'AnyWave';
content = 'continuous EEG, iEEG or MEG data';
% known Curry V4 file types
elseif filetype_check_extension(filename, '.dap')
type = 'curry_dap'; % FIXME, can also be MPI Frankfurt electrophysiological data
manufacturer = 'Curry';
content = 'data parameter file';
elseif filetype_check_extension(filename, '.dat')
type = 'curry_dat';
manufacturer = 'Curry';
content = 'raw data file';
elseif filetype_check_extension(filename, '.rs4')
type = 'curry_rs4';
manufacturer = 'Curry';
content = 'sensor geometry file';
elseif filetype_check_extension(filename, '.par')
type = 'curry_par';
manufacturer = 'Curry';
content = 'data or image parameter file';
elseif filetype_check_extension(filename, '.bd0') || filetype_check_extension(filename, '.bd1') || filetype_check_extension(filename, '.bd2') || filetype_check_extension(filename, '.bd3') || filetype_check_extension(filename, '.bd4') || filetype_check_extension(filename, '.bd5') || filetype_check_extension(filename, '.bd6') || filetype_check_extension(filename, '.bd7') || filetype_check_extension(filename, '.bd8') || filetype_check_extension(filename, '.bd9')
type = 'curry_bd';
manufacturer = 'Curry';
content = 'BEM description file';
elseif filetype_check_extension(filename, '.bt0') || filetype_check_extension(filename, '.bt1') || filetype_check_extension(filename, '.bt2') || filetype_check_extension(filename, '.bt3') || filetype_check_extension(filename, '.bt4') || filetype_check_extension(filename, '.bt5') || filetype_check_extension(filename, '.bt6') || filetype_check_extension(filename, '.bt7') || filetype_check_extension(filename, '.bt8') || filetype_check_extension(filename, '.bt9')
type = 'curry_bt';
manufacturer = 'Curry';
content = 'BEM transfer matrix file';
elseif filetype_check_extension(filename, '.bm0') || filetype_check_extension(filename, '.bm1') || filetype_check_extension(filename, '.bm2') || filetype_check_extension(filename, '.bm3') || filetype_check_extension(filename, '.bm4') || filetype_check_extension(filename, '.bm5') || filetype_check_extension(filename, '.bm6') || filetype_check_extension(filename, '.bm7') || filetype_check_extension(filename, '.bm8') || filetype_check_extension(filename, '.bm9')
type = 'curry_bm';
manufacturer = 'Curry';
content = 'BEM full matrix file';
elseif filetype_check_extension(filename, '.dig')
type = 'curry_dig';
manufacturer = 'Curry';
content = 'digitizer file';
elseif filetype_check_extension(filename, '.cdt')
type = 'curry_cdt';
manufacturer = 'Curry';
content = 'Curry8 data file';
elseif filetype_check_extension(filename, '.cef')
type = 'curry_cef';
manufacturer = 'Curry';
content = 'Curry event file';
elseif filetype_check_extension(filename, '.dpa')
type = 'curry_dpa';
manufacturer = 'Curry';
content = 'Curry8 sensor file';