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

Closes #1689 #1704

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open

Closes #1689 #1704

wants to merge 10 commits into from

Conversation

HenkMutsaerts
Copy link
Member

@HenkMutsaerts HenkMutsaerts commented Apr 29, 2024

Linked issue

Closes #1689

@HenkMutsaerts HenkMutsaerts self-assigned this Apr 29, 2024
@HenkMutsaerts HenkMutsaerts linked an issue Apr 29, 2024 that may be closed by this pull request
9 tasks
Copy link
Contributor

@jan-petr jan-petr left a 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+');
Copy link
Contributor

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+$');

Copy link
Member Author

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 :)

Copy link
Contributor

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)
Copy link
Contributor

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);
Copy link
Contributor

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

@jan-petr jan-petr assigned jan-petr and unassigned HenkMutsaerts Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Several bugs when processing
2 participants