I have this ListOfCoordinates list with 5 tuples (image below), with each index corresponding to the coordinates of two regions of the brain.
I also have this variable named brain_areas_ROIs, which is a dictionary (image below) with the names of all possible brain regions.
So I want to store in a dictionary the respective brain regions for all the pairs of coordinates obtained, like dict = {0: 'Frontal_Med_Orb_L', 'Frontal_Sup_Medial_L', 1: 'Frontal_Med_Orb_R', 'Frontal_Sup_Medial_L'}, so on and so on.
I’m really lost at this… any ideas?
Thanks in advance!
Advertisement
Answer
Does something like this work? I was not sure exactly what kind of variable you wanted. The two variables I used are shortened examples that you can fill with your data.
def main():
ListOfCoordinates = [
(2, 4),
(1, 5),
(6, 3),
(7, 0)
]
brain_areas_ROIs = {
0: "Precentral_L",
1: "Precentral_R",
2: "Frontal_Sup_L",
3: "Frontal_Sup_R",
4: "Frontal_Sup_Orb_L",
5: "Frontal_Sup_Orb_R",
6: "Frontal_Mid_L",
7: "Frontal_Mid_L"
}
print(brain_thing(ListOfCoordinates, brain_areas_ROIs))
def brain_thing(coordinates: list, brain_pos: dict) -> list:
brain_list = []
for coordinate in coordinates:
brain_list.append((brain_pos[coordinate[0]], brain_pos[coordinate[1]]))
return brain_list

