TE values as an adjacency matrix?

50 views
Skip to first unread message

Kayson Fakhar

unread,
Dec 4, 2023, 12:20:23 PM12/4/23
to IDTxl
Hi all,
Long time no see! I've been using Idtxl again after about two years and I see a lot has been improved. 

But I was wondering if there is an easy way of getting the actual TE values as an adjacency matrix? Let me explain a bit more, I'm doing a whole brain multivariate TE and MI analysis to compare these values with some other metrics like nodal strength, Euclidean distance, fiber length, functional connectivity, ... The idea is to see if it's possible to estimate the amount of transferred information between nodes from these metrics. I saw there's a question here already about how to access TE values and I did that, but then it's kind of cumbersome to put everything together as an adjacency matrix. I think it's very useful if the library can also provide that along the other metrics, like just passing "values" to weights when getting the adjacency matrix. But I was hoping that maybe you already have some tricks to get it as such without some dirty coding.
If not, perhaps I can write something and share mine if you find it useful.

P.S: Just to be sure before I actually get deep into this project, do you think if the TE/MI values are meaningful in this sense to be compared against other variables? My expectation is that, e.g., the stronger the weight, the more information is being transferred. Or the farther two nodes are, the less information they communicate.

Thanks a lot for the help and as always, this library is my first choice whenever I want to do any information theory analysis. Simple to use, nicely documented, and great support. 

p.wol...@gmail.com

unread,
Dec 9, 2023, 5:21:38 AM12/9/23
to IDTxl
Hi Kayson,
good to hear from you and good to hear, IDTxl is still helpful.

Regarding looking at estimated mTE values for further analysis: there are some caveats when comparing these estimates as estimation bias heavily depends on the number of samples and the dimensions used in the estimation. Therefore, a comparison is only fair if estimation parameters are held constant over the estimates being compared. If you are sure, no. dimensions and sample sizes are the same, further analysis of TE estimates is possible/meaningful. However, it might be a bit tricky to keep track of the variables entering the estimation of different links in mTE estimation using IDTxl's algorithm, which determines the dimensionality of the estimation problem. There is some functionality in IDTxl to perform network comparison while keeping the estimation bias constant (see this wiki page). Maybe this helps? 

If you would like to go ahead and add functionality to easily retrieve TE values as adjacency matrix, I am fairly sure, you would only need to add an additional branch in ResultsNetworkInference.get_adjacency_matrix. Let me know if you would like some assistance in implementing this. 

Best,
Patricia 

Jules Mitchell

unread,
Feb 14, 2024, 9:22:08 PMFeb 14
to IDTxl
Hi Kayson and Patricia, 

I am also looking to extract the TE values for my research. I've gone ahead and implemented this functionality in the results.py file:

Line 637: def get_adjacency_matrix(self, weights, fdr=True, weight_type=int): # Added weight_type arg. with 'int' default. When you call this function you can specify weight_type = float for the TE values. 

Line 668: adjacency_matrix = AdjacencyMatrix(self.data_properties.n_nodes, weight_type) # Added weight_type 

After the elseif weights == 'binary' branch, add the following (sorry about the formatting here):

elif weights == 'te': 
            for t in self.targets_analysed:
                single_result = self.get_single_target(target=t, fdr=fdr)
                sources = np.zeros(
                    len(single_result.selected_vars_sources), dtype=int)
                weights = np.zeros(
                    len(single_result.selected_vars_sources), dtype=weight_type) # Added weight_type 
                if single_result.selected_vars_sources is not None: # Checks if selected sources is none
                    sorted_sources = sorted(single_result.selected_vars_sources)  # Sorts selected sources to match with 'te' array order 
                    for i, s in enumerate(sorted_sources):
                        sources[i] = s[0]
                if single_result.te is not None:
                    for i, s in enumerate(single_result.te):
                        weights[i] = s
                adjacency_matrix.add_edge_list(
                    sources, np.ones(len(sources), dtype=int) * t, weights)

Then, 
weights = 'te'
adj_matrix = result.get_adjacency_matrix(weights=weights, fdr=False, weight_type=float)

Would sending a push request be the best approach to incorporate this? If not, happy for this code to be integrated on your end. 

Kind regards,

Jules

Kayson Fakhar

unread,
Feb 15, 2024, 4:22:46 AMFeb 15
to Jules Mitchell, IDTxl
Hi Jules,
That would be great because I got slowed down by wrapping up my PhD thesis.

--
You received this message because you are subscribed to a topic in the Google Groups "IDTxl" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idtxl/WmB0ONXm444/unsubscribe.
To unsubscribe from this group and all its topics, send an email to idtxl+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/idtxl/ba62bd44-0a3f-4c87-b114-a7ce4a87ab44n%40googlegroups.com.


--
Cheers,

Reply all
Reply to author
Forward
0 new messages