extraction of data from .dat file

8 views (last 30 days)
Matteo Martini
Matteo Martini on 15 May 2020
Hi Guys, I've looked everywhere but I don't seem to find a solution:
I have .dat files, with neurophysiological recordings of my participants, which contain both text and numbers, as you can see from the example below. What I need to do is:
1) Create a variable "Header" that contains only the initial 25 rows
2) Create new .dat files (or variables) from the original file which contain only data according to the position of the trigger "4" (that you can see in the first column of the numeric part of the file).
The first new .dat file will contain the data (all columns) included between the 26th row and the first "4". The second file will contain the data between the first "4" and the second "4", the third between the second "4" and the third "4", and so on........until the last file/variable which will contain the data between the last "4" and the end of the file.
3) Re-insert the Header part (the 25 rows of mixed stuff) at the beginning of each new .dat file (or new variable), to create .dat files with the header + the extract of the data.
Thank you so much in advance!!!!
P.S. the number of triggers may vary between 18 and 21 but the Header lines are always 25.
[Start/Stop Time]
START=2017/02/13 21:07:28
STOP=2017/02/13 22:27:06
[Measurement Profile]
TITLE=Mat Mar
EVENT_MODE=Event-Related
EVENT_TYPE=MANU
EVENT_T0=0,EVT1
EVENT_T1=0,EVT4
EVENT_T2=0,EVT3
EVENT_REPEAT=
[User Profile]
NAME=Mat Mar
AGE=64
GENDER=Female
Dominant Hand=Right-Handed
[HEADER]
TRG_MODE=8002
LED_POWER=0000
AGC_GAIN=0020,0010,0030,0020,0030,0050
[CH_CONFIG]
1,7,2,8,9,14,15,21,16,22,23,28,29,35,30,36
[CAL(CAL1-L1,CAL1-L2,...,CAL36-L1,CAL36-L2)(0:good/3:unuse/1:over/2:under)]
10,10,10,10,03,03,03,03,03,03,03,03,10,10,10,10,10,10,03,03,03,03,03,03,03,03,10,10,10,10,10,10,03,03,03,03,03,03,03,03,10,10,10,10,10,10,
[DATA(EVENT,CH1-L1(840nm),CH1-L2(770nm),...,CH36-L1,CH36-L2);FAST]
0000,1614,938,2405,1633,16,10,15,10,10,7,10,3,605,293,646,388,1708,1042,10
0000,1599,932,2397,1630,15,9,13,11,10,7,10,3,599,291,641,387,1699,1038,10,8
0000,1591,929,2391,1629,16,9,14,9,11,6,8,3,593,289,637,385,1691,1036,10,8,9
0004,1591,928,2392,1626,16,9,14,10,10,6,9,4,592,288,636,384,1690,1036,9,8,9
0000,1594,930,2393,1627,16,10,13,9,10,7,7,3,594,290,636,383,1691,1037,10,8,9
0000,1614,938,2405,1633,16,10,15,10,10,7,10,3,605,293,646,388,1708,1042,10
0004,1599,932,2397,1630,15,9,13,11,10,7,10,3,599,291,641,387,1699,1038,10,8
0000,1591,929,2391,1629,16,9,14,9,11,6,8,3,593,289,637,385,1691,1036,10,8,9
0000,1591,928,2392,1626,16,9,14,10,10,6,9,4,592,288,636,384,1690,1036,9,8,9
0000,1594,930,2393,1627,16,10,13,9,10,7,7,3,594,290,636,383,1691,1037,10,8,9
0000,1614,938,2405,1633,16,10,15,10,10,7,10,3,605,293,646,388,1708,1042,10
0004,1599,932,2397,1630,15,9,13,11,10,7,10,3,599,291,641,387,1699,1038,10,8
0000,1591,929,2391,1629,16,9,14,9,11,6,8,3,593,289,637,385,1691,1036,10,8,9
0004,1591,928,2392,1626,16,9,14,10,10,6,9,4,592,288,636,384,1690,1036,9,8,9
0000,1594,930,2393,1627,16,10,13,9,10,7,7,3,594,290,636,383,1691,1037,10,8,9
0000,1614,938,2405,1633,16,10,15,10,10,7,10,3,605,293,646,388,1708,1042,10
..................................................................

Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!