These are chat archives for thunder-project/thunder

3rd
Jan 2017
chenminyeh
@chenminyeh
Jan 03 2017 05:34
Hi, could anyone provide the order of axis for spatial ICA and provide some explanations? I have tried to load the data using image method (tzyx) and transformed them into series (zyxt). Both methods leads to same result: k replaced t for one of the outcome array. Many thanks!
Davis Bennett
@d-v-b
Jan 03 2017 05:48
@jwittenbach will know
Jason Wittenbach
@jwittenbach
Jan 03 2017 16:57
@chenminyeh take a look at the follow code:
import thunder as td
from factorization import ICA

data = td.images.fromrandom((10, 20, 20))
data.shape # prints (10, 20, 20)

s1, a1 = ICA(k=3).fit(data)
s1.shape # prints (10, 3)
a1.shape # (3, 20, 20)

s2, a2 = ICA(k=3).fit(data.toseries())
s2.shape # (20, 20, 3)
a2.shape # (3, 10)
I start with an Images object that is 10 20-by-20 images
Jason Wittenbach
@jwittenbach
Jan 03 2017 17:02
If I run ICA on this Images object with k=3, then I get 3 statistically independent time series, as well as 3 20-by-20 loading matrices telling me how to recomine them at each pixel to approximate the original data
On the other hand, if I convert to a Series object before I run ICA, then I get 3 statistically independing images, as well as 3 length-10 arrays telling me how to recombine them at each time point to approximate the original data
Maybe the best way to think about how thunder-factorization works is that it’s all about factorizing 2D matrices
and we interpret Images obejcts as simply ‘time-by-space’ (we actually flatten the images to make a 2D matrix and then unflatten at the end, just to help the user)
with ICA, all you’re doing is decoposing a matrix: X=HWX = HW
but the algorithm tries to make the columns of HH statistically independent
while there is no independence condition for WW
So when you do ICA on Images, which are ‘time-by-space’ you get independent time series and images of weights
Jason Wittenbach
@jwittenbach
Jan 03 2017 17:07
and when you do ICA on Series, which are are 'space-by-time' (just the transpose of the Images object), then you get independent images and time series of weights
So if by “spatial ICA”, you mean that you want independent images, then simply load the data to an Images object (I’m assuming it lives on disk as a bunch of images, so this will be the easiest way to load), convert to Series, and then pass that object to ICA. You’ll be back independent images as well as a matrix of weights.
chenminyeh
@chenminyeh
Jan 03 2017 17:19
Cool!! This makes everything much more clear!! Just one more thing: if PCA was used before ICA on the image file, it will give pca_k number of time traces which are decorrelated and use them for ICA? Many thanks!!