フィルターのクリア

Movefile and wtifc error

13 ビュー (過去 30 日間)
ibrahim halilullah
ibrahim halilullah 2023 年 11 月 7 日
コメント済み: Walter Roberson 2023 年 11 月 8 日
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" ) ;

回答 (1 件)

Walter Roberson
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 件のコメント
ibrahim halilullah
ibrahim halilullah 2023 年 11 月 8 日
Hi, thanks for the response I changed it to below but still getting the error for movefile.
[ ~, filename, ~, ] = fileparts(File.Name(ii).CropX) ;
Walter Roberson
Walter Roberson 2023 年 11 月 8 日
I recommend that you learn how to use fullfile to build file names.
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)

サインインしてコメントする。

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by