Movefile and wtifc error
13 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I am using a script to crop images at certain ROIs for further processing. During this I have had an issue and could not figure out what it may be. I tried the other solutions in the community but did not solve it. Any help would be highly appreciated.
Initially I received an error for wtifc which returned to:
TIFF library error - 'TIFFOpenW: C:\Users\A\Croppeddata\crop_X_1.tif: Cannot open.'
Error in writetif (line 110) wtifc(data, map, filename, writemode, colorspace, required_tags);
So I tried to instead try to move the problematic files that cause this issue with this:
Settings.num_planes(tryp_ind) = size(im1,3) ;
num_planes = Settings.num_planes(tryp_ind) ;
for kk = 1:File.num_t % for all the timepoints of the given position
ii = jj+kk -1 ;
im2 = TIFFStack(File.Name(ii).CropX) ;
im22 = uint16(im2( :,:, indk0_delta_2_all : indkf_delta_2_all)) ;
mkdir([File.pathname, filesep, 'trash']) ;
[ ~, ~, filename,] = fileparts(File.Name(ii).CropX) ;
movefile(File.Name(ii).CropX, [File.pathname, filesep, 'trash', filesep, filename, '.tif'], "f" ) ;
imwrite( im22(:,:,1), File.Name(ii).CropX, 'compression', 'none') ;
for m=2: size(im22,3)
imwrite( im22(:,:,m), File.Name(ii).CropX, 'WriteMode', 'append', 'compression', 'none') ;
end
But then this returned to:
Error using movefile
Cannot read from source: C:\Users\A\Croppeddata\crop_X_1.tif.
Error in cell_cropper_ (Line 755)
movefile(File.Name(ii).CropX, [File.pathname, filesep, 'trash', filesep, filename, '.tif'], "f" ) ;
0 件のコメント
回答 (1 件)
Walter Roberson
2023 年 11 月 7 日
[ ~, ~, filename,] = fileparts(File.Name(ii).CropX) ;
The third output from fileparts() is the file extension, not the file name.
2 件のコメント
Walter Roberson
2023 年 11 月 8 日
I notice that you are using Windows. It appears you are using https://www.mathworks.com/matlabcentral/fileexchange/32025-dylanmuir-tiffstack
I speculate that TIFFstack is opening the file, and that movefile() is potentially complaining because it is being asked to move a file that is already in use. But I do not know what the expected behaviour would be on Windows in such a case (I know what would happen on Linux or MacOS)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!