-
Notifications
You must be signed in to change notification settings - Fork 95
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
[ENH, FIX] Add wavelet denoising and fix t2smap workflow #90
Conversation
I have *no* clue if this works properly or not. Taken from https://github.com/ME-ICA/me-ica/blob/da6ac4c23a59145530a16bd6f25c676460 fe9436/meica.libs/tedana.py#L514-L518 and adjusted to work with pywt.idwt’s arguments (i.e., dropping correct_size argument).
Hopefully it works.
Codecov Report
@@ Coverage Diff @@
## master #90 +/- ##
===========================================
+ Coverage 27.95% 42.74% +14.79%
===========================================
Files 25 27 +2
Lines 1381 1516 +135
===========================================
+ Hits 386 648 +262
+ Misses 995 868 -127
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you ! I'm assuming this is still WIP from the travis errors ?
I had a few questions about variable names, but just wanted to say how great the addition is -- and the improved docstrings are a nice touch !
I just patched the circle error (finally) -- any chance you could merge in master, again ? Sorry for the trouble !
tedana/decomposition/_utils.py
Outdated
------- | ||
mmix_wt : :obj:`numpy.ndarray` | ||
Wavelet-transformed data. | ||
cAlen : :obj:`int` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to call it cAlen
here and cAl
in idwtmat()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied the functions from the old version of tedana and removed the correct_size
argument in idwtmat
, which pywt
must have dropped at some point.
tedana/decomposition/_utils.py
Outdated
llt = len(np.hstack(pywt.dwt(mmix[0], 'db2'))) | ||
mmix_wt = np.zeros([mmix.shape[0], llt]) | ||
for ii in range(mmix_wt.shape[0]): | ||
wtx = pywt.dwt(mmix[ii], 'db2') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the pywavelets documentation, it seems that wtx
would be the approximation coefficients for the specified row of mmix
. Then cAlen
would be the length of the first entry of wtx
in the last for-loop.
If you agree with that assessment, could we improve these variable names ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the approximation and detail coefficients, not that I'm sure what those are. cAlen
is the number of coefficients (i.e., len
of cA
). Oh, what about n_coefs_approx
instead of cAlen
, coefs_tup
instead of wtx
, n_coefs_total
instead of llt
, mmix_coefs
instead of mmix_wt
?
What does mmix
stand for again?
tedana/decomposition/_utils.py
Outdated
---------- | ||
mmix_wt : :obj:`numpy.ndarray` | ||
Wavelet-transformed data. | ||
cAl : :obj:`int` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comments ^
|
||
LGR.info('Computing optimal combination') | ||
tsoc = np.array(model.make_optcom(catd, t2s, tes, mask, combmode), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain these changes for me ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these changes are just taken from the current version of the tedana
workflow, except for changing the output variable names from the fit_decay
functions, which I did because I think the new ones are more informative. I also dropped the part where it writes out the t2ss
and s0vs
maps because fit_decay_ts
doesn't return those and I honestly have no clue what they are.
Are there any changes in particular that don't make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry, that wasn't a helpful question on my part ! Your explanation solved it anyway, though: I was confused why we were renaming tsoc
to OCcatd
.
Also, it looks like this may partially address #25 ? |
Also use more informative variable names in wavelet transformation functions.
The tests are now passing, and there are several working (though basic) tests for the t2smap workflow. Yay increased coverage! I guess it does address #25 a bit, though my changes are mostly to the workflow rather than the fitting functions. I'm not sure whether the wvpca works or not, but other than that I think it looks good. WDYT? |
Oh and I did notice two situations where
|
This is great ! 🎉 Do you think we should have some testing for the Regarding failing options: I had no idea the |
I can definitely add some simple tests. Something to make sure that the data are returned in the right shape at least. I don't know enough about wavelets to come up with anything better atm. Honestly, I had to hunt down a way to allow a test to fail. I didn't want to hide this weird condition that was failing but didn't want to have to deal with a continually breaking test, which would throw off the PRs once merged. By "not how tedana is" I meant that |
Do you think the failure has anything to do with this ? I can't find if we ever resolved that. |
We continued talking about the differences somewhere (maybe on Gitter?), but I can't find the discussion. Anyway, I don't think it could be the source of the failure, because my current version uses I just realized that I am changing how |
@@ -8,26 +8,27 @@ | |||
LGR = logging.getLogger(__name__) | |||
|
|||
|
|||
def make_optcom(data, t2s, tes, mask, combmode, verbose=True): | |||
def make_optcom(data, tes, mask, t2s=None, combmode='t2s', verbose=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emdupre I think we could probably consolidate these into one argument, but in the interest of clarity two is fine. If we move t2s
so it's a keyword argument, then it can default to None
(which works when combmode
is ste
but not when it's t2s
). Then below we check the inputs to make sure they make sense. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify: what would happen when combmode
is ste
if we make t2s the one (keyword) argument ? Or am I misunderstanding the suggestion ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe combmode = [t2s array]
and combmode = 'ste'
could be the two options? I admit, that's not the best suggestion... Or I guess when t2s = None
, ste is used by default? So it would be def make_optcom(data, tes, mask, t2s=None, verbose=True):
and if t2s
is an array, then t2s
combination is used, but if it's None
, then ste
combination is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me, unless we foresee adding other combmode
options.. @handwerkerd might have thoughts on this !
I had the same thought, but I can't find it anywhere ! I was having this same issue with the discussion we had on #88... I see your point about having For now, I'm happy to get circle passing again, move forward with the two argument idea, and reorganize |
Whoops, I missed one of the |
This LGTM ! I'll open a new issue re: a t2s keyword argument for Thanks again, @tsalo !! |
Closes #80.
Changes proposed in this pull request:
wvpca
argument totedana.decomposition.eigendecomp.tedpca
,tedana.workflows.tedana
, and thetedana
workflow CLI.t2smap
workflow, which hadn't been updated to work with the recent changes to the package.fitmode
, which can fit the mono exponential model per timepoint if desired.