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
Closes #1689 #1704
base: develop
Are you sure you want to change the base?
Closes #1689 #1704
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things
%% 1. Catch SPM suffixes | ||
[Fpath, Ffile, Fext] = fileparts(InputPath); | ||
|
||
[Ind1, Ind2] = regexp(Fext, ',\d+'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid bugs, best to look at endings only
',\d+$'
otherwise, it could find this in the middle of the path for weird cases like this... "/tmp/test,1Henk/file.nii"
if doing this, you can skip Ind2
Ind1 = regexp(Fext, ',\d+$');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[fPath, fFile, fExt] = fileparts('/tmp/test,1Henk/file.nii')
fPath =
'/tmp/test,1Henk'
fFile =
'file'
fExt =
'.nii'
I don't mind replacing this, but the Fext already has the end. It could still be any weird thing right?
E.g., we would catch fExt = '.nii,1.gz'
Anyway, I don't mind much here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. That example above will work. But I meant a weird case, but that is not likely to happen but in theory it could.
Like
[Fpath, Ffile, Fext] = fileparts('perfectlynormalifile/savedbyHenk.M.M.Mutsaerts,1April-withoutextension')
For that, we would loose a large part of the file as a supposedly SPM extension.
So my correction would be able to handle this without affecting the other functionality.
if ~isempty(Ind1) | ||
SuffixSPM = InputPath(Ind1:Ind2); | ||
InputPath = InputPath(1:Ind1-1); | ||
if Ind2~=length(Fext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above, we look for file endings only, so skip Ind2 and you don't need this condition again as this will never occur.
if Ind2~=length(Fext) | ||
error('Something wrong with this file extension'); | ||
else | ||
SuffixSPM = Fext(Ind1:Ind2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you replace Ind2 with end
Linked issue
Closes #1689