Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error writing .txt to /ecat_testing/steps folder #329

Open
fishpm opened this issue Jan 8, 2025 · 2 comments
Open

error writing .txt to /ecat_testing/steps folder #329

fishpm opened this issue Jan 8, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@fishpm
Copy link
Contributor

fishpm commented Jan 8, 2025

Describe the bug

If pet image created by ecat2nii requires rescaling, then ecat2nii.m tries to write scaling info to a .txt file saved to a folder (ecat_save_steps_dir) that is .../PET2BIDS/ecat_testing/steps, which does not exist in current PET2BIDS structure. Seems to me there are at least two straight-forward solutions: 1) write .txt file to .../PET2BIDS/matlab/ecat_testing, which does exist in current PET2BIDS structure, or 2) mkdir(ecat_save_steps_dir) if it does not exist. I am uncertain whether one is preferred for reasons about which I am unaware.

l. 202 - 220 of ecat2nii.m:

% rescale to 16 bits
rg = max(img_temp(:))-min(img_temp(:));
if rg ~= 32767 % same as range(img_temp(:)) but no need of stats toolbox
MaxImg = max(img_temp(:));
img_temp = img_temp/MaxImg*32767;
Sca = MaxImg/32767;
MinImg = min(img_temp(:));
if (MinImg<-32768)
img_temp = img_temp/MinImg*(-32768);
Sca = Sca*MinImg/(-32768);
end
% save scaling factor to file located at ecat_save_steps_dir/8.5_sca_matlab.txt
fid = fopen([ecat_save_steps_dir filesep '8.5_sca_matlab.txt'],'w');
fprintf(fid,'Scaling factor: %10e\n',Sca);
x = mh.ecat_calibration_factor * Sca;
fprintf(fid,'Scaling factor * ECAT Cal Factor: %10.10f\n',x);
fclose(fid);
end

To Reproduce
code: ecat2nii(filename{1},metadata);
error: Invalid file identifier. Use fopen to generate a valid file identifier.

Desktop (please complete the following information):

  • OS: Linux
  • matlab r2023a
@fishpm fishpm added the bug Something isn't working label Jan 8, 2025
@CPernet
Copy link
Contributor

CPernet commented Jan 8, 2025

@bendhouseart I do not remember writing this - did you do that?
@fishpm looks like we did that to test stuff as we had some issues -- and IMO that is not something user need to know (Claus does that all the time)

@fishpm
Copy link
Contributor Author

fishpm commented Jan 8, 2025

good to know, seems straight-forward to comment out/remove writing to the .txt file. i will make the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants