Skip to content

ICC_rep_anova speedup suggestion #3450

Closed
@kristoferm94

Description

@kristoferm94

Summary

ICC_rep_anova can be sped up by rearranging the matrix multiplication order and using the hermitian=True flag in pinv

Actual behavior

As implemented, pinv is called without the hermitian=True flag.
dot(X.T, X) will always be a hermitian matrix so speedup can be achieved by setting the hermitian flag in pinv to True.

The matrix multiplication in line 117 in icc.py is arranged in a way that fat matrices end up being multiplied together.
The matrix multiplication order can be rearranged in a way that we end up multiplying fat matrices with column vectors most of the time.

Script/Workflow details

Suggested modification in lines 117: https://github.com/kristoferm94/nipype/blob/linalg-speedup/nipype/algorithms/icc.py

I.e. replace:

predicted_Y = dot(dot(dot(X, pinv(dot(X.T, X))), X.T), Y.flatten("F"))

with

predicted_Y = X @ (pinv(X.T @ X, hermitian=True) @ (X.T @ Y.flatten("F")))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions