필터 지우기
필터 지우기

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