[FieldTrip] Problems with Fieldtrip MR/CT Processing, Workflow on PC

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Wed Feb 12 13:24:33 CET 2020


Dear Andrew and others,

Thanks for thinking along. In a recent version of the code, I thought I already addressed this issue. My solution was based on bypassing the section of freesurfer code that you refer to, because we now explicitly check whether a file is compressed (or a freesurfer_mgz image in combination with running the function on a PC), and decompess on-the-fly with gunzip, in ft_read_mri (around line 99 in ft_read_mri, using the private function inflate_file.m). A more principled solution could be indeed to fix it in load_nifti and PR to the freesurfer folks, and subsequently update our local copy that is shipped with FieldTrip. If it’s a clean fix, the freesurfer people typically acommodate such PRs, but the maintenance of their (often somewhat clunky) matlab code, does not seem to have priority. I suggest first that the Windows folks that have ran into problems recently update their FieldTrip version to one that is younger than December 2019 in order to check whether their problems persists, before taking any other action.

Best wishes,
Jan-Mathijs







> On 12 Feb 2020, at 12:28, Andrew Janke <floss at apjanke.net> wrote:
> 
> What do y'all think about replacing these zcat calls with something
> portable? Matlab has a gunzip() function, and the Java JRE that Matlab
> ships with includes some gzip stuff in java.util.zip, so you could
> accomplish this with native Matlab/Java code instead of calling out to
> the system's zcat utility. I could write up a PR for this if you're
> interested.
> 
> Or maybe I should send that PR directly to FreeSurfer instead of trying
> to patch the copy that's included with FieldTrip?
> 
> Cheers,
> Andrew
> 
> On 2/12/20 5:11 AM, Fellner, Marie-Christin wrote:
>> Hi Jonathon,
>> 
>> I have run into similar problems of you with nii.gz files on a PC even
>> with the most recent fieldtrip version.
>> 
>> The problem in my case was that the subfunction load_nifit.m used
>> commands that did not run using the windows command line. Downloading
>> and installing git (https://git-scm.com/) and crudely changing
>> load_nifit.m helped for me.
>> 
>> I just replaced  "cmd = sprintf('zcat %s > %s', niftifile,
>> new_niftifile);" to     "cmd = sprintf(' "C:\\Program
>> Files\\Git\\bin\\bash.exe " zcat -c %s > %s', niftifile, new_niftifile);"
>> 
>> Further change all  "  unix(sprintf('rm -f %s', niftifile)); " to  
>> "delete(niftifile);"
>> 
>> Hope that helps!
>> 
>> Best,
>> 
>> Marie
>> 
>> Am 07.02.2020 um 12:00 schrieb fieldtrip-request at science.ru.nl:
>>> Message: 4
>>> Date: Thu, 6 Feb 2020 23:33:08 +0000
>>> From: Jonathon James Parker<parkerjo at stanford.edu>
>>> To:"fieldtrip at science.ru.nl"  <fieldtrip at science.ru.nl>
>>> Subject: [FieldTrip] Problems with Fieldtrip MR/CT Processing Workflow
>>>     on PC
>>> Message-ID:
>>>     <BYAPR02MB575043282E5EC812196B677CAD1D0 at BYAPR02MB5750.namprd02.prod.outlook.com>
>>> 
>>>     
>>> Content-Type: text/plain; charset="windows-1252"
>>> 
>>> Dear Fieldtrippers:
>>> 
>>> I am working to setup my imaging analysis pipeline to co-localize my
>>> SEEG electrodes from CT with patient-specific MRIs.
>>> 
>>> I am running fieldtrip August 2019 Build with Matlab 2017a on a
>>> Windows 10 machine. I am running into some errors which I suspect are
>>> due to the freesurfer dependency.
>>> 
>>> When I run ft_hastoolbox(‘freesurfer’) it returns 1, which I don’t
>>> quite understand as I thought freesurfer was only Mac/Linux? When I
>>> look in my fieldtrip external directory there is a freesurfer folder
>>> with some matlab files in there.
>>> 
>>> Are you aware of any work-arounds that will allow me to process the
>>> CT/MR images still using fieldtrip?
>>> 
>>> The specific files I am processing are nii.gz (indentified by field
>>> trip as nifti_fsl)
>>> 
>>> When I call ft_read_mri() I get the following results:
>>> -----
>>> Uncompressing stan2_ct.nii.gz to /tmp/tmp2696491.nii
>>> The system cannot find the path specified.
>>> ERROR: could not read /tmp/tmp2696491.nii
>>> 'rm' is not recognized as an internal or external command,
>>> operable program or batch file.
>>> ERROR: loading stan2_ct.nii.gz as analyze
>>> Struct contents reference from a non-struct array object.
>>> 
>>> Error in ft_read_mri (line 396)
>>>      ndims = numel(size(tmp.vol));
>>> 
>>> Error in jpImagingPipeline (line 12)
>>> ct = ft_read_mri(ct_filename);
>>> 
>>> 
>>> Thanks in advance!
>>> 
>>> Jonathon J. Parker MD, PhD
>>> Resident in Neurosurgery
>>> Morgridge Endowed Postdoctoral Fellow
>>> Maternal & Child Health Research Institute
>>> Department of Neurosurgery
>>> Stanford University
>>> E:parkerjo at stanford.edu<mailto:parkerjo at stanford.edu>
>>> 
>>> 
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL:<http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200206/a0b682cd/attachment-0001.htm>
>>> 
>>> 
>>> ------------------------------
>>> 
>>> Message: 5
>>> Date: Fri, 7 Feb 2020 08:35:23 +0000
>>> From: "Schoffelen, J.M. (Jan Mathijs)"<jan.schoffelen at donders.ru.nl>
>>> To: FieldTrip discussion list<fieldtrip at science.ru.nl>
>>> Subject: Re: [FieldTrip] Problems with Fieldtrip MR/CT Processing
>>>     Workflow on PC
>>> Message-ID:<56E6D50D-81E1-464E-9256-221ABD935DDA at donders.ru.nl>
>>> Content-Type: text/plain; charset="utf-8"
>>> 
>>> Dear Jonathon,
>>> 
>>> Indeed, Freesurfer typically used to run only on Linux/Mac. However,
>>> rumour has it that as of Windows 10 , freesurfer might run on
>>> Windows. For this you’d need to check out the Freesurfer
>>> documentation. If you need to run the Freesurfer recon-all pipeline
>>> to extract cortical meshes and/or a surface hull, you’d need to find
>>> out how to execute this processing step yourself.
>>> 
>>> With respect to the message you get from ft_hastoolbox: this refers
>>> to the availability (to matlab) of the relevant freesurfer code that
>>> uses Matlab (which are mainly functions related to loading Freesurfer
>>> specific file-formats into matlab for further processing). These
>>> functions in principle should work also on windows, with one possible
>>> exception, and that is the on-the-fly decompression of compressed
>>> anatomical images, which seems to be the problem that you are running
>>> into. I improved the Windows support for reading in zipped MR-images
>>> (*.nii.gz, and *.mgz) last December, and on my end it seems to work
>>> with a current version of the FieldTrip code. I should note, however,
>>> that I recently ran a training event, where several participants
>>> still did not manage to read in the zipped files on their own
>>> (Windows) laptops. This could have been due to their strange keyboard
>>> layouts (German/French/Asian etc.), but more likely this was the
>>> consequence of an interaction between Windows version, Matlab version
>>> and the students’ position in the room.
>>> 
>>> Long story short: could you upgrade to a more recent version of the
>>> Fieldtrip code (early January onwards to be safe), and check whether
>>> your problem persists?
>>> 
>>> Best wishes,
>>> 
>>> Jan-Mathijs
>>> 
>>> J.M.Schoffelen, MD PhD
>>> Associate PI, VIDI-fellow - PI, language in interaction
>>> Telephone: +31-24-3614793
>>> Physical location: room 00.028
>>> Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands
>> 
>> 
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
> 
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202




More information about the fieldtrip mailing list