Tgspcread function error (line 323)
Ältere Kommentare anzeigen
I am attempting to use the tgspcread function in the Bioinformatics Toolbox to read a .spc file containing multiple spectra, but am receiving the following message. It had been working previous to updates to MATLAB, does anyone know how to solve it? Unfortunately my coding knowledge is pretty basic!
>> tgspcread('new.spc')
Reading header for file: new.spc
File contains 12826 scans
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Error in tgspcread (line 323)
outputHeader.FileSize = dirInfo.bytes;
Antworten (1)
Arthur Goldsipe
am 12 Feb. 2019
0 Stimmen
I think this is a bug in how the function tries to find out the size of the SPC file. You will see this error if the file is located in a folder that was added to MATLAB's path. The function fopen that opens the file is able to locate files on the MATLAB path, but the function dir that gives file information does not find files on the MATLAB path.
One solution is to change your current working directory to the folder that contains the SPC file before running the command. Another solution would be to specify the relative or absolute path to the file when you call tgspcread. For example, if you're using Linux, and the file is in the /tmp folder, you could update your line of code to tgspcread('/tmp/new.spc').
8 Kommentare
Katherine
am 12 Feb. 2019
Ewan Hislop
am 14 Feb. 2019
I am experiencing a similar problem with tgspcread function in the Bioinformatics Toolbox.
>> extract_data_AJ
Reading header for file: /Users/Ewan/Desktop/MATLAB/PC3 cm1/PC3 5uM DMSO x36 y37.spc
File contains 1332 scans
ans =
struct with fields:
Header: [1×1 struct]
X: [569×1 single]
Y: [569×1332 single]
Z: [1×1332 single]
Error using tgspcread (line 53)
Could not open file.
No such file or directory
Error in extract_lipid_fixed_AJ (line 6)
tgspcread(filename)
Error in extract_data_AJ (line 4)
[PC3_DMSO_5uM_1,shift,ratio1,ratio2,output]=
extract_lipid_fixed_AJ('/Users/Ewan/Desktop/MATLAB/PC3 cm1\PC3 5uM DMSO x36
y37.spc',36,37);
Can anyone please help?
Arthur Goldsipe
am 14 Feb. 2019
Hi Ewan,
Your error looks different. Your error suggests that fopen couldn't find the file, which I think means the file does not exist. I would double-check your code to make sure that there's not a typo.
I don't know what extract_lipid_fixed_AJ does, since you didn't provide the code for that. It looks like it successfully reads one spc file and then errors when trying to read another file. You can try using the debugger to see what filename is causing the error, and then you can make sure this file really exists.
-Arthur
Ewan Hislop
am 14 Feb. 2019
It seems to fail
Error using tgspcread (line 53)
Could not open file.
No such file or directory
Error in extract_lipid_fixed_AJ (line 5)
tgspcread(filename)
When I click on this error Error using tgspcread (line 53) it links me to
bioinfochecknargin(nargin,1,mfilename);
[zrange,scanindices,verbose,headeronly] = parse_inputs(varargin{:});
[fid, theMessage] = fopen(filename,'rb','l');
if fid == -1
error(message('bioinfo:tgspcread:CouldNotOpenFile', theMessage));
end
dirInfo = dir(filename);
c = onCleanup(@()fclose(fid));
if(verbose)
fprintf('Reading header for file: %s\n',filename);
end
Does this make any sense?
Sorry my Matlab experience is basic.
Regards,
Ewan
Arthur Goldsipe
am 14 Feb. 2019
Sorry, but it's stil hard to know exactly what's going on without seeing the contents of extract_lipid_fixed_AJ. It still looks like you're trying to open a file that doesn't exist. I can't teach you all the details of how to debug here, but I'll offer one quick tip. Before running your script, type dbstop if error at the MATLAB command prompt. This will pause you in the debugger when MATLAB encounters an error. Then run your script. This should cause you to stop on the line of code where the file can't be found. Then, type filename at the MATLAB command prompt to see what file you're trying to open. Please confirm that this file actually exists.
Arthur Goldsipe
am 14 Feb. 2019
I think the probem is that you're mixing forward slashes, /, and backslashes, \. I'm guessing you're using a Mac and need to change to consistently using forward slashes. Note that the first time you call tgspcread, it works because you're always using forward slashes. But the second time it fails because you're mixing in backslashes.
Ewan Hislop
am 14 Feb. 2019
Thank you! This has been driving me mad all day. :)
Arthur Goldsipe
am 15 Feb. 2019
Hi Ewan,
This is getting outside the scope of the original question, and it's a bit hard to follow along via comments. (It also makes it harder for other people with similar problems to find the solutions.) I recommend you make a new post in MATLAB Answers. If possible, I suggest attaching any relevant files so that other people can try to reproduce the problem.
-Arthur
Kategorien
Mehr zu DICOM Format finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!