<commit_before>### NIfTI: haxby ##############################################################

# Haxby: Fetch data
from nisl import datasets
haxby = datasets.fetch_haxby()

# Haxby: Get the files relative to this dataset
files = haxby.files
bold = files[1]

# Haxby: Load the NIfTI data
import nibabel
data = nibabel.load(bold).get_data()

# Haxby: Visualization
import numpy as np
from matplotlib import pyplot
pyplot.figure()
pyplot.subplot(131)
pyplot.axis('off')
pyplot.title('Coronal')
pyplot.imshow(np.rot90(data[:, 32, :, 100]), interpolation='nearest',
    cmap=pyplot.cm.gray)
pyplot.subplot(132)
pyplot.axis('off')
pyplot.title('Sagittal')
pyplot.imshow(np.rot90(data[15, :, :, 100]), interpolation='nearest',
    cmap=pyplot.cm.gray)
pyplot.subplot(133)
pyplot.axis('off')
pyplot.title('Axial')
pyplot.imshow(np.rot90(data[:, :, 32, 100]), interpolation='nearest',
    cmap=pyplot.cm.gray)
pyplot.show()

### Matlab: kamitani ##########################################################

# Kamitani: Fetch data
from nisl import datasets
kami = datasets.fetch_kamitani()

# Kamitani: Load matlab data
from scipy import io
mat = io.loadmat(kami.files[0], struct_as_record=True)
# Kamitani: get the scans for random images (20 sessions)
data = mat['D']['data'].flat[0]['random'].flat[0].squeeze()
# Kamitani: take the data of the first scan of the first session
scan = data[0][:, 0]

# Kamitani: voxels are flattened, and there is an index (volInd) to get their
# 3D coordinates. We have to use volInd and xyz (which gives MNI coordinates)
# to get back to a 3D matrix
ijk = mat['D']['xyz'].flat[0] / 3 - 0.5 + [[32], [32], [15]]
volInd = mat['D']['volInd'].flat[0].squeeze()
fullscan = np.zeros((64, 64, 30))
for i, v in enumerate(scan):
    fullscan[tuple(ijk[:, volInd[i]])] = v

# Kamitani: Visualization
import numpy as np
from matplotlib import pyplot as pl
pyplot.figure()
pyplot.subplot(131)
pyplot.axis('off')
pyplot.title('Coronal')
pyplot.imshow(np.rot90(fullscan[:, 8, :]), interpolation='nearest',
    cmap=pyplot.cm.gray)
pyplot.subplot(132)
pyplot.axis('off')
pyplot.title('Sagittal')
pyplot.imshow(np.rot90(fullscan[21, :, :]), interpolation='nearest',
    cmap=pyplot.cm.gray)
pyplot.subplot(133)
pyplot.axis('off')
pyplot.title('Axial')
pyplot.imshow(np.rot90(fullscan[:, :, 12]), interpolation='nearest',
    cmap=pyplot.cm.gray)
pyplot.show()<commit_msg>COSMIT: simplify the visualization example<commit_after>""" Simple example to show data manipulation and visualization.
"""

### NIfTI: haxby ##############################################################

# Haxby: Fetch data
from nisl import datasets
haxby = datasets.fetch_haxby()

# Haxby: Get the files relative to this dataset
files = haxby.files
bold = files[1]

# Haxby: Load the NIfTI data
import nibabel
data = nibabel.load(bold).get_data()

# Haxby: Visualization
import numpy as np
import pylab as pl
pl.figure()
pl.subplot(131)
pl.axis('off')
pl.title('Coronal')
pl.imshow(np.rot90(data[:, 32, :, 100]), interpolation='nearest',
          cmap=pl.cm.gray)
pl.subplot(132)
pl.axis('off')
pl.title('Sagittal')
pl.imshow(np.rot90(data[15, :, :, 100]), interpolation='nearest',
          cmap=pl.cm.gray)
pl.subplot(133)
pl.axis('off')
pl.title('Axial')
pl.imshow(np.rot90(data[:, :, 32, 100]), interpolation='nearest',
          cmap=pl.cm.gray)
pl.show()


{'fraction_non_alphanumeric': 0.2106363907977293, 'fraction_numerical': 0.03226770242007768, 'mean_word_length': 5.669322709163347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '197218', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1206, 'n_words': 283}