コード例 #1
0
ファイル: analysis.py プロジェクト: agramfort/nipype
    def _make_output_figures(self):
        """
        Generate the desired figure and save the files according to
        self.inputs.output_figure_file

        """
        
        if self.inputs.figure_type == 'matrix':
            fig_coh = viz.drawmatrix_channels(self.coherence,
                                channel_names=self.ROIs,
                                color_anchor=0)
        
            fig_coh.savefig(fname_presuffix(self.inputs.output_figure_file,
                                    suffix='_coherence'))

            fig_dt = viz.drawmatrix_channels(self.delay,
                                channel_names=self.ROIs,
                                color_anchor=0)
        
            fig_dt.savefig(fname_presuffix(self.inputs.output_figure_file,
                                    suffix='_delay'))
        else:
            fig_coh = viz.drawgraph_channels(self.coherence,
                                channel_names=self.ROIs)
        
            fig_coh.savefig(fname_presuffix(self.inputs.output_figure_file,
                                    suffix='_coherence'))

            fig_dt = viz.drawgraph_channels(self.delay,
                                channel_names=self.ROIs)
        
            fig_dt.savefig(fname_presuffix(self.inputs.output_figure_file,
                                    suffix='_delay'))
コード例 #2
0
    def _make_output_figures(self):
        """
        Generate the desired figure and save the files according to
        self.inputs.output_figure_file

        """
        if self.inputs.figure_type == 'matrix':
            fig_coh = viz.drawmatrix_channels(self.coherence,
                                              channel_names=self.ROIs,
                                              color_anchor=0)

            fig_coh.savefig(fname_presuffix(self.inputs.output_figure_file,
                                            suffix='_coherence'))

            fig_dt = viz.drawmatrix_channels(self.delay,
                                             channel_names=self.ROIs,
                                             color_anchor=0)

            fig_dt.savefig(fname_presuffix(self.inputs.output_figure_file,
                                           suffix='_delay'))
        else:
            fig_coh = viz.drawgraph_channels(self.coherence,
                                             channel_names=self.ROIs)

            fig_coh.savefig(fname_presuffix(self.inputs.output_figure_file,
                                            suffix='_coherence'))

            fig_dt = viz.drawgraph_channels(self.delay,
                                            channel_names=self.ROIs)

            fig_dt.savefig(fname_presuffix(self.inputs.output_figure_file,
                                           suffix='_delay'))
コード例 #3
0
ファイル: test_viz.py プロジェクト: ilustreous/nitime
def test_drawgraph_channels():

    fig04 = drawgraph_channels(C.corrcoef, roi_names)
コード例 #4
0
ファイル: test_viz.py プロジェクト: derekrollend/nitime
def test_drawgraph_channels():
    fig04 = drawgraph_channels(C.corrcoef, roi_names)
コード例 #5
0
"""

Extract the coherence and average across the same frequency bands as before:

"""

coh = np.mean(coh[:, :, freq_idx], -1)  # Averaging on the last dimension
"""

Finally, in this case, we visualize the adjacency matrix, by creating a network
graph of these ROIs (this is done by using the function drawgraph_channels
which relies on `networkx <http://networkx.lanl.gov>`_):

"""

fig04 = drawgraph_channels(coh, roi_names[idx])
"""

.. image:: fig/resting_state_fmri_04.png

This shows us that there is a stronger connectivity between the left putamen and
the left caudate than between the homologous regions in the other
hemisphere. In particular, in contrast to the relatively high correlation
between the right caudate and the left caudate, there is a rather low coherence
between the time-series in these two regions, in this frequency range.

Note that the connectivity described by coherency (and other measures of
functional connectivity) could arise because of neural connectivity between the
two regions, but also due to a common blood supply, or common fluctuations in
other physiological measures which affect the BOLD signal measured in both
regions. In order to be able to differentiate these two options, we would have
コード例 #6
0
Extract the coherence and average across the same frequency bands as before:

"""


coh = np.mean(coh[:, :, freq_idx], -1)  # Averaging on the last dimension

"""

Finally, in this case, we visualize the adjacency matrix, by creating a network
graph of these ROIs (this is done by using the function drawgraph_channels
which relies on `networkx <http://networkx.lanl.gov>`_):

"""

fig04 = drawgraph_channels(coh, roi_names[idx])

"""

.. image:: fig/resting_state_fmri_04.png

This shows us that there is a stronger connectivity between the left putamen and
the left caudate than between the homologous regions in the other
hemisphere. In particular, in contrast to the relatively high correlation
between the right caudate and the left caudate, there is a rather low coherence
between the time-series in these two regions, in this frequency range.

Note that the connectivity described by coherency (and other measures of
functional connectivity) could arise because of neural connectivity between the
two regions, but also due to a common blood supply, or common fluctuations in
other physiological measures which affect the BOLD signal measured in both
コード例 #7
0
ファイル: fmri4.py プロジェクト: fperez/nitime
#This part is the same as before
TR=1.89
data_rec = csv2rec('data/fmri_timeseries.csv')
roi_names= np.array(data_rec.dtype.names)
n_samples = data_rec.shape[0]
data = np.zeros((len(roi_names),n_samples))

for n_idx, roi in enumerate(roi_names):
   data[n_idx] = data_rec[roi]

data = percent_change(data)
T = TimeSeries(data,sampling_interval=TR)
T.metadata['roi'] = roi_names 
C = CoherenceAnalyzer(T)
freq_idx = np.where((C.frequencies>0.02) * (C.frequencies<0.15))[0]

idx_lcau = np.where(roi_names=='lcau')[0]
idx_rcau = np.where(roi_names=='rcau')[0]
idx_lput = np.where(roi_names=='lput')[0]
idx_rput = np.where(roi_names=='rput')[0]

idx = np.hstack([idx_lcau,idx_rcau,idx_lput,idx_rput])
idx1 = np.vstack([[idx[i]]*4 for i in range(4)]).ravel()
idx2 = np.hstack(4*[idx])

#Extract the coherence and average across these frequency bands: 
coh = C.coherence[idx1,idx2].reshape(4,4,C.frequencies.shape[0])
coh = np.mean(coh[:,:,freq_idx],2) #Averaging on the last dimension

drawgraph_channels(coh,roi_names[idx])