.MAT to .Dat issue

7 visualizzazioni (ultimi 30 giorni)
Robert Mayger
Robert Mayger il 26 Ago 2020
Commentato: dpb il 26 Ago 2020
I am trying to convert the data from a series of 4 .mat MEG trails (4 sensors x651 recording) to a .dat file for analysis. When I try to use dlmwrite not all sensors are included in the .dat file and when i try to convert using -ascii the .dat file alters the format of the data from a single ERP to continous data spikes. Does anyone know of another way to create my .dat file. Kind regards
  3 Commenti
Robert Mayger
Robert Mayger il 26 Ago 2020
the program (spm) that I am using requires the waveform information to be seperated into a .dat file inorder to be read, I will attach the entire .mat file, besa_sourcewaveforms_all.waveforms is the variable that I am trying to extract, I have also added figures for how the .dat files appear in my program, they are labelled accordingly to the process I used.
I dont have any extensive code but the code I did use followed the formats previously suggested on mathworks
dlmwrite code - dlmwrite('SUB01.dat',[waveforms])
ascii code - save('SUB01.dat', 'waveforms', '-ascii')
dpb
dpb il 26 Ago 2020
>> whos -file SUB01_besa_source.mat
Name Size Bytes Class Attributes
besa_sourcewaveforms 1x1 29448 struct
besa_sourcewaveforms_all 1x15 430064 struct
>> load SUB01_besa_source.mat
>> besa_sourcewaveforms
besa_sourcewaveforms =
struct with fields:
structtype: 'besa_sourcewaveforms'
labels: {'SD-1' 'SD-2' 'SD-3' 'SD-4'}
waveforms: [651×4 double]
numberoftrials: 141
condition: 'ISI200_R_M'
samplingrate: 1000
type: 'GRA'
latencies: [1×651 double]
datafile: 'C:\Documents and Settings\All Users\Documents\ADAPT\SUB06 (28-07-2010) New analysis\Sub006_MH_GRANDAVERAGE_av_new.fsg'
modelname: 'C:\Documents and Settings\All Users\Documents\ADAPT\SUB06 (28-07-2010) New analysis\ECD_Solution\Sub006_MH_4ECD_Solution_new.bsa'
headmodel: 'MEG spherical'
regularization: 0.0100
filters: '1 - 100 Hz NF:50'
>>
It's a struct with a field waveforms, the other is an array of those.
dlmwrite('yourfilename',besa_sourcewaveforms.waveforms)
will write the array to the file as .csv; I forget the default precision (6 significant digits, maybe???)
BTW, dlmwrite has been deprecated; TMW suggests using writematrix instead.
>> dlmwrite('besa_sourcewaveforms.csv',besa_sourcewaveforms.waveforms(1:10,:))
>> type besa_sourcewaveforms.csv
0,0,0,0
0,0,0,0
0.017103,0.012915,0.015769,0.0070932
0.073439,0.050682,0.041433,0.014394
0.13735,0.084326,0.019121,-0.00096016
0.14264,0.066736,-0.050773,-0.0085693
0.072304,-0.024836,-0.064302,0.060108
-0.010435,-0.18761,0.079103,0.2102
0.006966,-0.39497,0.3814,0.36595
0.20388,-0.58668,0.74595,0.45235
>>
>> besa_sourcewaveforms.waveforms(1:10,:)
ans =
0 0 0 0
0 0 0 0
0.0171 0.0129 0.0158 0.0071
0.0734 0.0507 0.0414 0.0144
0.1373 0.0843 0.0191 -0.0010
0.1426 0.0667 -0.0508 -0.0086
0.0723 -0.0248 -0.0643 0.0601
-0.0104 -0.1876 0.0791 0.2102
0.0070 -0.3950 0.3814 0.3660
0.2039 -0.5867 0.7460 0.4523
>>
Illustrates does work as advertised...so, we can't see what you actually did, but code snippet posted doesn't have meaning on its own as there is no variable waveforms so it's unknown how you created it. Dereference the struct and all should be well...

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Data Types in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by