關(guān)于nifti文件的int16和float32數(shù)據(jù)類型的問(wèn)題

有時(shí)候用 spm12的Display選項(xiàng)打開nifti之后發(fā)現(xiàn)nifti數(shù)據(jù)文件的數(shù)據(jù)類型是不一樣的,比如int16和float32,會(huì)心生疑惑,兩種數(shù)據(jù)類型對(duì)數(shù)據(jù)分析有影響嗎?
事實(shí)上子刮,nifti文件的大小就但等于dimensions乘以數(shù)據(jù)類型的長(zhǎng)度,比如下圖中數(shù)據(jù)大小應(yīng)該是646433*16=2162688位窑睁,換算成Kb應(yīng)該是2162688/1024/8=264Kb,那我們?cè)賮?lái)看一下這個(gè)nifti文件的大小呢挺峡?如圖所示,確實(shí)是265Kb担钮。

image.png
image.png

至于nifti的int16與32float有什么區(qū)別橱赠,我覺得下面的這個(gè)回答還算滿意(原文鏈接:https://afni.nimh.nih.gov/afni/community/board/read.php?1,137005,137007):


giuseppe pagnoni Wrote:


I have noticed that when copying NIFTI data (from
a Philips scanner) with 3dcopy, an automatic
conversion from INT16 to FLOAT32 seems to be
taking place [...]
But why is that
happening? Is there a way to keep the original
format? If the data are originally INT16, it
seems to me that you waste a lot of disk space and
computing time by doubling the size of the data
right away.

In my understanding int16 was used in AFNI in the old days, when disk space was expensive. Nowadays disk space is quite cheap, so it's not too much of an issue.

When using int16, data is stored together with a min value p and max value q; each value v is then stored as an int16 i with v=p + s*i, where s=(q-p)/(2^16-1) is the step size. When having a few outliers (extreme values) q-p is large so the step size s is large too. This reduces the resolution for the rest of the data (which is usually the data of interest). In addition, every processing step usually involves some averaging of existing values that have to be converted back to an int16, which again impoverishes the data (even if during computations the data is stored internally as float32).

Float32 does not have this disadvantage as it holds an exponent, allowing for a large range of data and yet good numerical precision.
Therefore float32 is currently considered as the preferred option by most.

Also note that you can enable compression which reduces file sizes considerably, and this compression works transparently in the AFNI programs. One way is to specify an extension for the output file (e.g. -prefix output.nii.gz to store in nifti and gzip the output). Another approach is to set the environmental variable AFNI_COMPRESSOR to BZIP2 or GZIP so that AFNI compresses the data automatically.


簡(jiǎn)單而言,就是如果你空間足夠箫津,還是用float32方便狭姨。

20190319

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市苏遥,隨后出現(xiàn)的幾起案子饼拍,更是在濱河造成了極大的恐慌,老刑警劉巖田炭,帶你破解...
    沈念sama閱讀 218,284評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件师抄,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡教硫,警方通過(guò)查閱死者的電腦和手機(jī)叨吮,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,115評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)栋豫,“玉大人挤安,你說(shuō)我怎么就攤上這事谚殊∩パ欤” “怎么了?”我有些...
    開封第一講書人閱讀 164,614評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵嫩絮,是天一觀的道長(zhǎng)丛肢。 經(jīng)常有香客問(wèn)我,道長(zhǎng)剿干,這世上最難降的妖魔是什么蜂怎? 我笑而不...
    開封第一講書人閱讀 58,671評(píng)論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮置尔,結(jié)果婚禮上杠步,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好幽歼,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,699評(píng)論 6 392
  • 文/花漫 我一把揭開白布朵锣。 她就那樣靜靜地躺著,像睡著了一般甸私。 火紅的嫁衣襯著肌膚如雪诚些。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,562評(píng)論 1 305
  • 那天皇型,我揣著相機(jī)與錄音诬烹,去河邊找鬼。 笑死弃鸦,一個(gè)胖子當(dāng)著我的面吹牛绞吁,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播唬格,決...
    沈念sama閱讀 40,309評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼掀泳,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了西轩?” 一聲冷哼從身側(cè)響起员舵,我...
    開封第一講書人閱讀 39,223評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎藕畔,沒想到半個(gè)月后马僻,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,668評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡注服,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,859評(píng)論 3 336
  • 正文 我和宋清朗相戀三年韭邓,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片溶弟。...
    茶點(diǎn)故事閱讀 39,981評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡女淑,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出辜御,到底是詐尸還是另有隱情鸭你,我是刑警寧澤,帶...
    沈念sama閱讀 35,705評(píng)論 5 347
  • 正文 年R本政府宣布擒权,位于F島的核電站袱巨,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏碳抄。R本人自食惡果不足惜愉老,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,310評(píng)論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望剖效。 院中可真熱鬧嫉入,春花似錦焰盗、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,904評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至映九,卻和暖如春梦湘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背件甥。 一陣腳步聲響...
    開封第一講書人閱讀 33,023評(píng)論 1 270
  • 我被黑心中介騙來(lái)泰國(guó)打工捌议, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人引有。 一個(gè)月前我還...
    沈念sama閱讀 48,146評(píng)論 3 370
  • 正文 我出身青樓瓣颅,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親譬正。 傳聞我的和親對(duì)象是個(gè)殘疾皇子宫补,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,933評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容