開始使用免費開始

平移(Translations)

在本章中,你將運用來自 Open Access Series of Imaging Studies 的資料,來比較不同族群的大腦:年輕與年長、男性與女性、健康與疾病。

先從一個 3D 大腦體積(im)中的單一切片開始,將它置中。你需要先在影像陣列中找到幾何中心點,以及大腦的質心(center of mass)。接著,將影像平移到中心位置。

本章所有練習都已匯入以下套件:

import imageio.v2 as imageio
import numpy as np
import scipy.ndimage as ndi
import matplotlib.pyplot as plt

本練習屬於課程

Python 的生醫影像分析

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Find image center of mass
com = ____

# Calculate amount of shift needed
d0 = 128 - _____
d1 = ____

# Translate the brain towards the center
xfm = ndi.shift(____, shift=____)
編輯並執行程式碼