<jupyter_start><jupyter_text>Example Notebook for loading and analysing data from the 2D-morphologies dataset<jupyter_code>import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
import aira_data_utils
from aira_data_utils.aira_data_utils import AIRADataset
from aira_data_utils.analysis import get_p1_value, get_p2_vector, get_dataset_p1_distribution, get_segmented_ds
# dataset = AIRADataset('./data.h5', img_size=64, dataset_type='tiny', download=True)
dataset = AIRADataset('./data.h5', img_size=64, dataset_type='tiny')
sample_imgs = dataset.generate_thumbnails()
plt.imshow(sample_imgs, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculation of P1 value for a sample<jupyter_code>example_img = dataset[0]
plt.imshow(example_img, cmap='gray')
print('P1 value of image: {}'.format(get_p1_value(example_img)))<jupyter_output>P1 value of image: 0.5577938556671143<jupyter_text>Calculation of P2 correlation vector for a sample<jupyter_code>p2_vec = get_p2_vector(example_img)
sns.set()
plt.figure()
plt.title('P2 vector for example img')
plt.xlabel('Radial distance $r$')
plt.ylabel('P2 correlation value')
plt.plot(p2_vec)
#plt.hist([get_p1_value(i) for i in dataset], bins=20)
fig = plt.figure()
ax = get_dataset_p1_distribution(dataset, bins=20)
fig.add_axes(ax)
plt.show()<jupyter_output><empty_output><jupyter_text>Iterating over the dataset The dataset class supports iterations and slicing similar to that of Numpy Arrays<jupyter_code>sns.set_style({"axes.grid":False})
ds = dataset[0:2]
plt.subplot(211)
plt.imshow(ds[0], cmap='gray')
plt.subplot(212)
plt.imshow(ds[1], cmap='gray')
for idx, i in enumerate(dataset):
    plt.subplot(210+idx+1)
    plt.imshow(i, cmap='gray')
    if idx == 1:
        break<jupyter_output><empty_output><jupyter_text>Segmented Dataset The dataset can be segmented over p1 values as well.<jupyter_code>ds = get_segmented_ds(dataset[0:30], p1_range=(0.45, 0.5))
ax = get_dataset_p1_distribution(ds, bins=100)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11972180824639841, 'fraction_numerical': 0.03626428216592151, 'mean_word_length': 8.031390134529149, 'pattern_counts': {'":': 1, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '87291', 'license': 'MIT', 'n_tokens_mistral': 805, 'n_tokens_neox': 749, 'n_words': 156, 'path': 'Example.ipynb', 'repo_name': 'shahviraj/2d-morphologies-data-utils', 'size': '2013'}