sburns / recon-stats

Parse stats outputs from recon-all
4 stars 5 forks source link

Doesn't work for Freesurfer 5.3 #3

Open KirstieJane opened 10 years ago

KirstieJane commented 10 years ago

If you run recon-stats with data processed using Freesurfer 5.3 you get the following error:

response = p.import_records([data])

RequestException Traceback (most recent call last)
in () 15 data[p.def_field] = '87654' # or however this subject is indexed in your REDCap 16 data['redcap_event_name'] = p.events[2]['event_name'] ---> 17 response = p.import_records([data])
C:\Users\Kirstie\Anaconda\lib\site-packages\pycap-0.9-py2.7.egg\redcap\project.pyc in import_records(self, to_import, overwrite, format, return_format, return_content, date_format) 420 response = self._call_api(pl, 'imp_record')[0] 421 if 'error' in response: --> 422 raise RedcapError(str(response)) 423 return response 424
RequestException: {u'fields': [u'recon_lhsurfaceholes_lhsurfaceholes', u'recon_estimatedtotalintracranialvol_etiv', u'recon_brainsegvol-to-etiv_brainsegvol-to-etiv', u'recon_mask_maskvol', u'recon_supratentorialnotventvox_supratentorialvolnotventvox', u'recon_brainsegnotventsurf_brainsegvolnotventsurf', u'recon_supratentorialnotvent_supratentorialvolnotvent', u'recon_maskvol-to-etiv_maskvol-to-etiv', u'recon_rhsurfaceholes_rhsurfaceholes', u'recon_surfaceholes_surfaceholes'], u'error': u'The following fields were not found in the project'}

Basically all it's saying is that some of the field names that are in the recon-stats dictionary aren't variable names in the REDCap instrument.

I've written the following hack that has to be run after:

data = s.upload_dict()

and before

response = p.import_records([data])

Here it is:

# We need a little hack that renames certain fields because
# the REDCap instrument was made for Freesurfer 5.1 ...
data['recon_intracranialvol_icv'] = data.pop('recon_estimatedtotalintracranialvol_etiv')
data['recon_brainmask_brainmaskvol'] = data.pop('recon_mask_maskvol')

# ... and deletes some other fields that are not yet in the REDCap instrument
data.pop('recon_surfaceholes_surfaceholes', None)
data.pop('recon_lhsurfaceholes_lhsurfaceholes', None)
data.pop('recon_rhsurfaceholes_rhsurfaceholes', None)
data.pop('recon_maskvol-to-etiv_maskvol-to-etiv', None)
data.pop('recon_supratentorialnotvent_supratentorialvolnotvent', None)
data.pop('recon_supratentorialnotventvox_supratentorialvolnotventvox', None)
data.pop('recon_brainsegnotventsurf_brainsegvolnotventsurf', None)
data.pop('recon_brainsegvol-to-etiv_brainsegvol-to-etiv', None)
sburns commented 10 years ago

This is more an issue with the REDCap shared library than recon-stats, agreed? I think we need to make a new shared library for 5.3

sburns commented 10 years ago

Would you mind sending me example *.stats files that generate these different keys? I should add them to the theoretical unit testing....

KirstieJane commented 10 years ago

Yes - you're right - I think it would be nice to make a REDCap library for 5.3 separately.

How would you like me to send the files? I don't think they're too big but there are quite a few...

sburns commented 10 years ago

recon-stats just parses:

(ref)

What if you fork, add them in a test folder, & send a pull-request? I'd like to have your contribution "on the record". Obviously remove any identifiers...