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

Reading freesurfer stats files correctly #1152

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

simkarwin
Copy link

No description provided.

there was a problem with reading the stats files
@effigies
Copy link
Member

A couple thoughts:

  1. Why a class with only static methods? I think flat functions would make more sense and be consistent with this module.

  2. Is it possible to do what you want with plain numpy? Pandas is a very heavy dependency that we are unlikely to make an installation requirement.

@simkarwin
Copy link
Author

The code has been revised regard to your comments

@codecov
Copy link

codecov bot commented Dec 10, 2022

Codecov Report

Patch coverage: 35.71% and project coverage change: -0.08 ⚠️

Comparison is base (b7022e0) 92.16% compared to head (c3c3e04) 92.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1152      +/-   ##
==========================================
- Coverage   92.16%   92.08%   -0.08%     
==========================================
  Files          98       98              
  Lines       12364    12378      +14     
  Branches     2539     2543       +4     
==========================================
+ Hits        11395    11398       +3     
- Misses        646      657      +11     
  Partials      323      323              
Impacted Files Coverage Δ
nibabel/freesurfer/io.py 90.83% <35.71%> (-3.42%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I've made a couple comments.

A larger question is whether this is intended to be for any stats files in FreeSurfer, or just the ones generated by mris_anatomical_stats? We might want to do some detecting of the kind of stats in order to correctly build a dtype. I imagine a column header -> dtype lookup table would not be too difficult to construct.

What do you think?

nibabel/freesurfer/io.py Show resolved Hide resolved
nibabel/freesurfer/io.py Outdated Show resolved Hide resolved
nibabel/freesurfer/io.py Outdated Show resolved Hide resolved

Examples
--------
>>> stats_a2009, column_names = read_stats_file(r'lh.aparc.a2009s.stats')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to have example code, it needs to run. We could drop an example file in nibabel/tests/data/ and access it with

from nibabel.testing import test_data
stats_a2009 = read_stats_file(test_data(fname='lh.aparc.a2009s.stats'))

simkarwin and others added 3 commits April 5, 2023 03:53
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
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.

None yet

2 participants