Hi, I am trying to use LCmodel to analyze some older Siemens MRS data for which I only have DICOM file, no Siemens *.raw. I want to convert the data to the LCmodel *.RAW file.
Most data are series of spectra, so I would like to put them in *.RAW files with multiple spectra as columns (NDCOLS >1).
So far no luck with either single spectra or series. The *.RAW input format appears to be very finicky. I get ZEROVOX 5 errors again and again.
I tried with/without an extra newline after the last data point, with or without quotes around the FMTDAT and/or ID statements (Jamie’s code would produce without quotes, but LCmodel’s test.RAW file has quotes. I also tried FMTDAT = ‘(2E1.6)’, FMTDAT = ‘(2E15.6)’ or FMTDAT = ‘(2E16.6)’. Nothing works.
Below is the core of the write to RAW Matlab script I wrote based on Jamie Near’s io_writelcmraw.m.
Also, the control files produced in my efforts have the right number of columns, but the LCMgui shows 1 column every time in spite of the NDCOLs = 5 in the RAW parameters.
Can anybody help me get this right?
N = spectra(1).hdr.fid_size;
data = zeros( M * spectra(1).hdr.fid_size, 2);
idx = 1:N;
for ii = 1:M
idx = (1:N)+(ii-1)*N;
thesedata = spectra(ii).data(:);
thesedata = conj(thesedata);
data(idx, 1:2) = [real(thesedata), imag(thesedata) ];
end % for ii
% write to .RAW txt file for LCmodel
fprintf(fid,’ $SEQPAR\n’); % begin sequence paramters
fprintf(fid,’ ECHOT = %-3.1f\n’, 1000*spectra(1).hdr.TE);
fprintf(fid,’ HZPPPM=%-12.4f\n’, spectra(1).hdr.frequency);
fprintf(fid,’ DELTAT=%-15.8f\n’, 1/spectra(1).hdr.sweepwidth );
fprintf(fid,’ NUNFIL=%-6d\n’, N );
fprintf(fid,’ NDCOLS=%-3d\n’, M );
fprintf(fid,’ NDROWS=%-3d\n’, 1 );
fprintf(fid,’ SEQ = ‘’%s’’\n’, sequence );
fprintf(fid,’ $END\n’); % end sequence paramters
fprintf(fid,’ $NMID\n’); % begin format/scale paramters
fprintf(fid,’ ID=’’%s’’\n’, filename(1:20) );
fprintf(fid,’ $END\n’); % end format/scale paramters
fprintf(fid,’ % 15.6E % 15.6E\n’, data’); %space after “%” sign forces hanging negative sign