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

DNM: Add fALFF, PerAF, and tSNR outputs #1030

Closed
wants to merge 25 commits into from
Closed

Conversation

tsalo
Copy link
Member

@tsalo tsalo commented Jan 9, 2024

Add resting-state metric outputs.

Changes proposed in this pull request

  • Retain fitted intercept parameter estimates from denoising step as "mean BOLD" image, for later PerAF and tSNR calculation.
  • Pass the uncensored_denoised_bold data to the ALFF calculation node instead of interpolated_filtered_bold, so ALFF and fALFF aren't calculated from bandpass filtered data.
  • Add tSNR, PerAF, and fALFF outputs.

@tsalo tsalo changed the title Add fALFF and PerAF outputs. Add fALFF, PerAF, and tSNR outputs Jan 11, 2024
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: Patch coverage is 95.45455% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.43%. Comparing base (b2d16c1) to head (e539e7a).
Report is 317 commits behind head on main.

Files with missing lines Patch % Lines
xcp_d/interfaces/restingstate.py 90.90% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1030      +/-   ##
==========================================
+ Coverage   82.33%   82.43%   +0.10%     
==========================================
  Files          48       48              
  Lines        5897     5949      +52     
  Branches      796      802       +6     
==========================================
+ Hits         4855     4904      +49     
  Misses        839      839              
- Partials      203      206       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tsalo tsalo added the enhancement New feature or request label Jan 16, 2024
Copy link
Contributor

@mattcieslak mattcieslak left a comment

Choose a reason for hiding this comment

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

The only thing I'd be sure to add is a check for nan/inf values in percent alff

write_ndata(
mean_bold,
template=self.inputs.preprocessed_bold,
filename=self._results["mean_bold"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does self._results get created?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's created automatically by the class, I believe. I define self._results["mean_bold"] in the line before this I think (344).

# Lomb-Scargle periodogram will have the same scale.
voxel_data_censored -= np.mean(voxel_data_censored)
voxel_data_censored /= np.std(voxel_data_censored)

time_arr = np.arange(0, n_volumes * TR, TR)
assert sample_mask.size == time_arr.size, f"{sample_mask.size} != {time_arr.size}"
time_arr = time_arr[sample_mask]
Copy link
Contributor

Choose a reason for hiding this comment

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

0.5 * fs is the nyquist frequency?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it should be.


assert alff.size == n_voxels, f"{alff.shape} != {n_voxels}"

# Add second dimension to array
# Add second dimension to arrays
Copy link
Contributor

Choose a reason for hiding this comment

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

I like to use .reshape(-1, 1) for padding, but I don't think there's an official best way to do it

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually think the Numpy-preferred method might be numpy.expand_dims, but I don't feel strongly about it.

@mattcieslak mattcieslak marked this pull request as ready for review January 17, 2024 15:52
@tsalo tsalo changed the title Add fALFF, PerAF, and tSNR outputs DNM: Add fALFF, PerAF, and tSNR outputs Aug 7, 2024
@tsalo tsalo marked this pull request as draft August 7, 2024 17:23
@tsalo tsalo closed this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants