Use a textscan to read information from a mass spectra file
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
How a create a function to do a textscan, to read and organizate the values.
SPECTRUM - MS,Freire_CBA25_esineg20V_1609201101_110912095815.raw,ITMS - c ESI Full ms,[150.00-2000.00],Scan #: 1,RT: 0.00,Data points: 26,Mass Intensity,252.288330 3.752531,654.839478 4.112705,628.720276 1.040182,670.929688 2.301675,831.274719 4.198380,831.876343 4.999859,832.701721 2.565361,833.744324 8.549965,834.917542 2.106223,836.011963 1.116679,837.476624 1.962655,875.554382 9.931887,877.245544 12.885395,878.321594 3.647082,879.508057 8.777822,881.555603 1.955709,920.309875 1.123865,921.557190 3.406728,923.486328 4.776421,992.530273 1.446173,1038.756958 1.730710,1118.263672 1.373949,1141.833618 1.513801,1142.635864 1.629417,1155.645264 1.375273,1199.954102
The first comma represents the analysis this always will have the same number of strings (SPECTRUM - MS)
The second comma represents the name of the sample the quantity of strings can change. (Freire_CBA25_esineg20V_1609201101_110912095815.raw)
The third comma represents the method I don't know if have a diferents quantity of strigsfor this part, perhaps it has the same. (ITMS - c ESI Full ms)
The fourth comma represents the range of the values of mass ( in this case between 100 and 1200 UA, [150.00-2000.00])
The fifth comma represents the number of the scan (Scan #: 1)
The sixth comma represents the Retention time (RT: 0.00)
The seventh comma represents the quantity of data points ( Data points: 26)
The eighth comma reprensents the mass intensity (Mass Intensity)
After those commas come the X,Y datas
252.288330 3.752531
654.839478 4.112705
... ...
I had this function to read the similar data but from another equipment
function mass_read=mass_reader(txtfile)
fid = fopen(txtfile);
mass_read = textscan(fid,'%f,%1s,%3s,%3s,%1s,%4s,%f%f,%f,%s','Delimiter',...
'','CollectOutput',1,'bufsize',250000);
mass_read{end} = cellfun(@(x) textscan(x,'%f %f','Delimiter',',',...
'CollectOutput',1),mass_read{1,end});
fclose(fid);
I dont't know if help but....
Thanks and best regards
1 Kommentar
Walter Roberson
am 21 Sep. 2011
Thank you for explaining all of the fields of the header; that kind of information is useful.
Which (if any) of the header fields do you want to import?
Akzeptierte Antwort
Fangjun Jiang
am 21 Sep. 2011
Copy your text data to a file called test.txt and use the following code.
txtfile='test.txt';
fid = fopen(txtfile);
mass_read = textscan(fid,'%s','Delimiter',',');
data= cellfun(@(x) textscan(x,'%f %f','Delimiter',' ',...
'CollectOutput',1),mass_read{1});
fclose(fid);
Array=cell2mat(data(9:end-1))
Array =
1.0e+003 *
0.252288330000000 0.003752531000000
0.654839478000000 0.004112705000000
0.628720276000000 0.001040182000000
0.670929688000000 0.002301675000000
....
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!