<jupyter_start><jupyter_text>Assignment of an MNI coordinate to Julich-Brain probabilistic cytoarchitectonic maps`siibra` can use the probabilistic maps of the Julich-Brain cytorachitectonic atlas to make a probabilistic assignment of a coordinate with error radius (modelled as a Gaussian) to brain regions.<jupyter_code># some coordinates  in MNI space, e.g. from an EEG contact
points = siibra.PointSet([
    (31.0, -89.6, -6.475),  # a real sEEG contact point
    (27.75, -32.0, 63.725)    # this should be in PostCG, right hemisphere
          ], space="mni152")

# a confidence radius for the coordinate, i.e. the expected localization error.
radius_mm = 5<jupyter_output><empty_output><jupyter_text>We instantiate the human atlas with the Julich-brain probabilistic cytoarchitectonic maps, and then ask it to assign regions. It will return a sorted list of probabilities with the corresponding regions.<jupyter_code>atlas = siibra.atlases.MULTILEVEL_HUMAN_ATLAS
julich_pmaps = atlas.get_map(
    space="mni152", 
    parcellation="julich",
    maptype="continuous")
assignments = julich_pmaps.assign_coordinates(points,radius_mm)<jupyter_output><empty_output><jupyter_text>We look at the best fitting maps at the first requested location.<jupyter_code>for region,pmap,scores in assignments[0]:
    if scores['contains']>.5: 
        plotting.plot_stat_map(
            pmap, 
            cut_coords=tuple(points[0]),
            title=f"{region.name} ({scores['contains']*100:.1f}%)"
        )<jupyter_output><empty_output><jupyter_text>Connectivity profiles of the most probable brain region`siibra`'s key feature is access to regional data features, including connectivity profiles from different projects. This can be used to check the connection strengh of the most likely region assignment to the MNI coordinate.<jupyter_code># get profiles for the top assigned region 
closest_region,pmap,scores = next(iter(assignments[0]))
profiles = siibra.get_features(
    closest_region,
    siibra.modalities.ConnectivityProfile)<jupyter_output><empty_output><jupyter_text>We will create plots of the connection strength to the 20 most strongly connected regions, for each of the returned profiles. Note that the profiles come from different connectivity datasets. The `src_info` and `src_name` attributes tell us more about each dataset.First, we decode the profiles with the parcellation object. This will convert the column names of the connectivity profile to explicit brain region objects, helping to disambiguiate region names.<jupyter_code>with siibra.QUIET:
    decoded_profiles = [
        p.decode(closest_region.parcellation)
        for p in profiles]
p = decoded_profiles[0]
target_regions = [region for strength,region in p[:20]]
target_regions<jupyter_output><empty_output><jupyter_text>We build a plotting function for the decoded profiles, which takes the N most strongly connected regions of the first profile, and then plots the connection strengths of all found profiles for those N target regions.<jupyter_code>import matplotlib.pyplot as plt
%matplotlib inline

# a function to create a nice plot of multiple profiles from different
# data sources
def plot_connectivity_profiles(profiles,target_regions):
    # Let's plot the so obtained regions and their strenghts
    N = len(target_regions)
    xticks = range(N)
    fig  = plt.figure()
    ax1  = fig.add_subplot(211)
    ax1.set_xticks(xticks)
    ax1.set_xticklabels(
        [r.name for r in target_regions], 
        rotation=45, fontsize=10, ha='right')
    
    for p in profiles:
        probs = {region:prob for prob,region in p}
        y = [probs[r] if r in probs else 0 
             for r in target_regions ]
        strengths = []
        ax1.plot(xticks,y,'.-',lw=1)

    ax1.grid(True)
    return fig
fig = plot_connectivity_profiles(decoded_profiles,target_regions)
fig.legend([p.name for p in profiles],
           loc='upper left', bbox_to_anchor=(1.05, 1.0),
           prop={'size': 9})
fig.gca().set_title(f"Connection strengths from area {closest_region.name}")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08140385084084815, 'fraction_numerical': 0.015110894467462832, 'mean_word_length': 4.435761589403974, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '420745', 'license': 'Apache-2.0', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1219, 'n_words': 407, 'path': 'examples/Probabilistic_assignment.ipynb', 'repo_name': 'sdiazpier/siibra-python', 'size': '4103'}