IniziaInizia gratis

The structure of .mat in Python

Here, you'll discover what is in the MATLAB dictionary that you loaded in the previous exercise.

The file 'albeck_gene_expression.mat' is already loaded into the variable mat. The following libraries have already been imported as follows:

import scipy.io
import matplotlib.pyplot as plt
import numpy as np

Once again, this file contains gene expression data from the Albeck Lab at UCDavis.

Questo esercizio fa parte del corso

Introduction to Importing Data in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Use the method .keys() on the dictionary mat to print the keys. Most of these keys (in fact the ones that do NOT begin and end with '__') are variables from the corresponding MATLAB environment.
  • Print the type of the value corresponding to the key 'CYratioCyt' in mat. Recall that mat['CYratioCyt'] accesses the value.
  • Print the shape of the value corresponding to the key 'CYratioCyt' using the numpy function shape().
  • Execute the entire script to see some oscillatory gene expression data!

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Print the keys of the MATLAB dictionary
print(____)

# Print the type of the value corresponding to the key 'CYratioCyt'


# Print the shape of the value corresponding to the key 'CYratioCyt'


# Subset the array and plot it
data = mat['CYratioCyt'][25, 5:]
fig = plt.figure()
plt.plot(data)
plt.xlabel('time (min.)')
plt.ylabel('normalized fluorescence (measure of expression)')
plt.show()
Modifica ed esegui il codice