簡體   English   中英

沿一個軸縮放/歸一化 3D 個數據點?

[英]Scale/normalize 3D data points along one axis?

對於一個研究項目,我被要求使用 3D 椎骨界標對不同類型的脊柱彎曲進行分類。

3D 2位患者的脊柱標志圖

我希望這些情節或多或少看起來像什么

由於我的目標是只關注曲率,因此我需要縮放/歸一化沿 Z 軸的 3D 線,因為患者的身高和體型不同。 我不確定如何在保持 x 軸和 y 軸相對於 z 的關系的同時解決這個 z 軸縮放問題。

print(spine_landmark_data_x.head(1).T)
print(spine_landmark_data_y.head(1).T)
print(spine_landmark_data_z.head(1).T)

上面代碼中的 Output 個數據幀(X、Y、Z 坐標在 3 個單獨的數據幀中)

test_x = spine_landmark_data_x.copy()
test_y = spine_landmark_data_y.copy()
test_z = spine_landmark_data_z.copy()

# Scale each patient z-axis from 0 to 1
for row in range(spine_landmark_data.shape[0]):
    test_z.iloc[row] = spine_landmark_data_z.iloc[row] - spine_landmark_data_z.iloc[row].min()
    test_z.iloc[row] = test_z.iloc[row] / test_z.iloc[row].max()
    
    test_y.iloc[row] = spine_landmark_data_y.iloc[row] - spine_landmark_data_y.iloc[row].min()
    test_y.iloc[row] = test_y.iloc[row] / test_y.iloc[row].max()
    
    test_x.iloc[row] = spine_landmark_data_x.iloc[row] - spine_landmark_data_x.iloc[row].min()
    test_x.iloc[row] = test_x.iloc[row] / test_x.iloc[row].max()

上面代碼產生的圖

以下會起作用嗎?

test_x = spine_landmark_data_x.copy()
test_y = spine_landmark_data_y.copy()
test_z = spine_landmark_data_z.copy()

# Scale each patient z-axis from 0 to 1
for row in range(spine_landmark_data.shape[0]):
    # scaling factor = 1.0 / (patient's z data range)
    scaling_factor = 1.0 / (spine_landmark_data_z.iloc[row].max() - spine_landmark_data_z.iloc[row].min())
    test_z.iloc[row] = (spine_landmark_data_z.iloc[row] - spine_landmark_data_z.iloc[row].min()) * scaling_factor
    test_y.iloc[row] = (spine_landmark_data_y.iloc[row] - spine_landmark_data_y.iloc[row].min()) * scaling_factor
    test_x.iloc[row] = (spine_landmark_data_x.iloc[row] - spine_landmark_data_x.iloc[row].min()) * scaling_factor

它與您現有的代碼略有不同,因為它按用於將 z 范圍標准化為 [0, 1] 的相同因子縮放所有軸。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM