Movefile and wtifc error
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 7 Nov 2023
[ ~, ~, filename,] = fileparts(File.Name(ii).CropX) ;
The third output from fileparts() is the file extension, not the file name.
2 commentaires
Walter Roberson
le 8 Nov 2023
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)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!