wadpac / GGIR

Code corresponding to R package GGIR
https://wadpac.github.io/GGIR/
Apache License 2.0
94 stars 60 forks source link

in g.report.part2 f0 does not get rescaled to length(fnames) if too large #1064

Closed vincentvanhees closed 6 months ago

vincentvanhees commented 6 months ago

Issue reported in https://groups.google.com/d/msgid/RpackageGGIR/f831fe09-63ba-4b95-95fe-8e578b99a351n%40googlegroups.com

Hello!

I was encountering this same error and think I figured out the issue. I was recently running a GGIR shell script (GGIR version: 3.0.5) to process selected data files within a larger directory. To do so, I specified f0 = 14 and f1 = 16. However, each time I ran the script it crashed during the function g.report.part2. I debugged the error in R Studio and noticed a potential issue with the code and found a workaround I wanted to share. GGIR_error.jpg The code above is a screenshot from g.report.part2. The following for loop iterates through i = 14, 15, 16 in my case. However, since the total number of files in the fnames vector is 3, attempting to access fnames[i] (which only contains 3 files) results in a null ending to the file path "fname2read". This causes the function to crash creating the error below. Error_Message.jpg As a workaround, I simply copied the files to a new directory and changed the path in "datadir" to point to this new directory. I then left f0 = 1 and removed f1 (since it defaults to the length of the directory). This fixed my error and allowed me to run a subset of all my .gt3x files.

Hopefully this helps!

Sincerely, Michael Melville