huppertt / nirs-toolbox

Toolbox for fNIRS analysis
86 stars 61 forks source link

How to use ApplyROI with multiple ROIs #1

Closed rob-luke closed 3 years ago

rob-luke commented 4 years ago

Dear Professor Huppert,

I recently updated to the latest commit and found that my usage of ApplyROI no longer works. I have been unable to determine how long ago the change happened based on commit hashes (I assume due to the mercurial git changeover) and I foolishly had deleted my previous mercurial download 🤦.

When I run ApplyROI with multiple ROIs (following the format in docs) I get the following error:

Undefined function 'isnan' for input arguments of type 'cell'.

Error in nirs.util.ROIhelper (line 51)
    if(any(all([isnan(R{idx}.detector) isnan(R{idx}.source)],2)))

I have suggested two code changes in the pull request. First, I added a unit test to demonstrate the issue I encountered. Second, I have proposed a solution that modifies the ApplyROI input format to be suitable for roiAverage. I decided to modify the ApplyROI function as this seemed the most backwards compatible solution (no change to documentation required).

It may also be that I have misunderstood how to use the ApplyROI function, if so I would be happy to update the documentation if you can inform me of a better way to specify multiple ROIs.

Thanks for the great package, Rob