Giter Club home page Giter Club logo

filtershift_c's Introduction

filtershift.cc

Filtershift.cc is a c++ module for fMRI preprocessing developed by QNL in the Cognitive Neuroscience Division of the Columbia University Medical Center Neurology Department. Filtershift uses the principles of digital signal processing and ideal signal reconstruction to optimally resample a time series at a constant offset. It also (optionally) filters the data using an optimized kaiser-window LPF.

Reference:

Parker, David, Xueqing Liu, and Qolamreza R. Razlighi. "Optimal slice timing correction and its interaction with fMRI parameters and artifacts." Medical Image Analysis 35 (2017): 434-445.

Help

Application

Filtershift is a slice timing correction routine. If you use Filtershift in your preprocessing pipeline, you should remove all other slice timing correction modules (also known as temporal realignment).

Notes

"Slice Timing" file VS "Slice Order" File

Slice Order:

This is the typical slice order format. "Row" indicates the order in which the slices are acquired (Slice acquired 1st, slice acquired 2nd, etc), "val" indicates the physical slice index that was acquired.

Row Val
1 1
2 3
3 5
4 7
5 2
6 4
7 6
8 8

In this example, row 2 - val 3 means slice 3 was acquired 2nd. row 5 - val 2 means slice 2 was acquired 5th, and so on

Slice Timing

This is the typical slice timing format. "Row" indicates the physical slice index, and "Val" indicates the time at which that slice was acquired. For example, row 1 is the time of slice 1's acquisition, row 2 is the time of slice 2's acquisition, etc

Row Val
1 0.000
2 0.500
3 0.033
4 0.533
5 0.066
6 0.566
7 0.100
8 0.600

Now in this case, row 2 val 0.500 means slice 2 was acquired 0.500 seconds after the first slice acquired in the volume. Row 5 val 0.066 means slice 5 was acquired 0.066 seconds after the start of the first slice slice acquired in the volume.

Multiband

Slice Timing

Multiband works fine with a slice timing file. You just manually set the time that each slice was acquired in a way that accounts for the simultaneous acquisition of multiple slices. For example:

Row Val
1 0.000
2 0.666
3 0.333
4 1.000
5 0.000
6 0.666
7 0.333
8 1.000

This will correctly account for slices 1, 4, and 7 being acquired simultaneously at time 0.000s, slices 3 and 6 being acquired simultaneously at time 0.500s, and slices 2, 5, and 8 being acquired simultaneously at time 1.000s.

Slice Order

The program can detect a multiband slice order file. The format of the multiband slice order file is fundamentally different from the slice order file for a sequential volume. Please read the descriptions of each, and ensure that you fully understand the differences.

Multiband slice order files use the following format, which means slice "row" was acquired "val"

Row Val
1 1
2 3
3 2
4 4
5 1
6 3
7 2
8 4

Now in this case, row 2 val 3 means slice 2 was acquired 3rd. Row 5 val 1 means slice 5 was acquired 1st. Note that this example is equivalent to the example given for the multiband slice Timing file. You would basically put the order in if you were too lazy to just calculate the time shifts yourself. Yes, I'm looking at you.

Basic Installation

Binary File

You can simply download the binary executable file "filtershift" and add it to a directory of your choice. Then, modify your .bashrc file so your PATH variable includes that directory.

Manual Compile

You can manually compile the source code yourself, however this requires that you have fsl 5.0.7 or later installed on your machine.

1. Navigate to the "src" folder in your FSL directory ('/usr/local/fsl/5.0.7' or similar)
2. In the "src" folder, create a new directory called "filtershift"
3. Download the associated *.h and *.cc files to this directory
4. in the FSL 5.0.7 directory, call the "build" file in terminal, with the argument "filtershift":
./build filtershift

Note: you will need superuser access to do this successfully.

5. you should now be able to run ./filtershift from a new terminal window, providing your FSL paths are set up correctly.

Using filtershift

filtershift --in <InputFile> --tr <TR> [options]

Compulsory arguments (You MUST set one or more of):
	--in		filename the input image to perform STC on

	--TR		Set the TR of the original fMRI data in seconds


filtershift --in <InputFile> --tr <TR> [options]
	 If no other options are set, this assumes ascending
	 Slice order with no interleave.

	 To use with a slice Order file, the TR must be
	 specified, and slices will be shifted according to
	 a fractional amount of the TR.  By default, we align
	 to the first slice acquired in the TR.

	 To use a slice timing file, no TR is required,
	 simply provide the desired shift in seconds as a
	 Column vector, saved in a text file.  Slice
	 Shifting is independent of all other slices,
	 so multiple slices can be shifted the same amount
	 (To correct multi-band acquisition, for example)


Compulsory arguments (You MUST set one or more of):
	-i,--in	 filename the input image to perform STC on


Optional arguments (You may optionally specify one or more of):
	-h,--help	 display this message

	--TR	 Set the TR of the original fMRI data in seconds

	--itl	 set the interleave parameter, or how many slices are
			 incremented between acquisitions
			 1 = sequential acquisition
			 2 = even/odd acquisition (acquire every second slice)
			 3 = acquire every third slice, etc
			 Leaving this blank will assume bottom up sequential
			 acquisition

	-o,--out	 Specify an output file name - all working directories
			 will be created in the parent directory specified
			 here. Leave blank to run in the parent directory
			 of <InputFile>

	-s,--start	 Set the starting slice - The slice that was acquired
			 first in the sequence. Default is slice 1, the bottom
			 most slice. This starts the interleave from that slice.
			 If your interleave parameter is '1' and your starting
			 slice is '3', your slice acquisition sequence will be
			 modeled as:
				 3
				 5
				 7
				 9...

	-d,--direction	 value 1 or -1.  Set the direction of slice 
			 acquisition.
			 1: ascending slice acquisition:(1,3,5,7,9...)
			-1: descending slice acquisition: (9,7,5,3,...)

	--order		 Slice Order File.  This file is the order in which
			 each slice was acquired. each row represents the
			 order in which that slice was acquired. For example,
			 '1' in the first row means that slice 1 was acquired
			 first. '20' in the second row means that slice 20 was
			 acquired 2nd. If present, all interleave parameters
			 are ignored, and slices are shifted using the slice
			 order file. we refer to the bottom slice in the image
			 as slice 1, not slice 0

	--cf		 Set the cutoff frequency of the lowpass filter in Hz.
			 Note that by default, this is set to 0.21 Hz.

	--timing	 Slice Timing File.  This file is the time at which
			 each slice was acquired relative to the first slice.
			 each row represents the time at which that slice was
			 acquired. For example, '0' in the first row means
			 that slice 1 was acquired first, and will be shifted 0
			 seconds. '0.5' in the second row means that slice 2
			 was acquired 0.5 seconds after the first slice, and
			 will be shifted 0.5s. If present, all interleave
			 parameters are ignored, and slices are shifted using
			 the slice timing file. If you put both a slice timing
			 and a slice order, the program will yell at you and
			 refuse to run.

	-r,--reference	 Set the Reference slice
			 This is the slice the data is aligned to.
			 Default is the first slice

	--lpf	 Only Run the Lowpass Filter, do not
			 Preform slice timing correction

About QNL

QNL Homepage

filtershift_c's People

Contributors

dpark6060 avatar

Stargazers

Grégory Hammad avatar Daisuke MATSUYOSHI avatar Martin Domin avatar Aaron Newman avatar Daniel Gomez avatar Chris Gorgolewski avatar

Watchers

 avatar FelixH avatar  avatar

filtershift_c's Issues

Abort: terminate called after throwing an instance of 'std::length_error'

Hi,
I wanted to use FilterShift 1.4 for comparison to FSL slicetimer. I ran it on resting-state data from the enhanced NKI sample (TR1.4, 404 volumes, 2mm iso) with the following command and got the appended message:
$filtershift -i prefiltered_func_data_mcf.nii.gz -o prefiltered_func_data_filtershift.nii.gz --TR=1.4 --itl=2
Reading input volume
Raw N:
639.411
640
0
terminate called after throwing an instance of 'std::length_error'
what(): vector::reserve
Abort

This is my OS:
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u1 x86_64
FSL(5.0.9) slicetimer worked with the following commands:
$slicetimer -i prefiltered_func_data_mcf.nii.gz -o prefiltered_func_data_slicetimer.nii.gz -r 1.4 --odd
The used data you find here:
https://fz-juelich.sciebo.de/index.php/s/LY6VI4V2o5O1Eek

I would be happy, if you could comment on that.
Thanks,
Felix

Can't run -- Mission non-optional argument!

I can't get either master or the latest release to run because regardless of my inputs I always get a message saying that flitershift is missing non-optional arguments. Is a particular order of arguments required to get it to run?

filtershift -i sub-01_task-block_acq-slc30_bold.nii.gz --TR 1.56 --itl 2 -d 1 -o sub-01_task-block_acq-slc30_preproc-stc_bold.nii.gz

Thank you - looking forward to trying FilterShift!

Cannot run binary file

Thanks very much for the release of this module.

I am trying to use it to correct MB EPIs but I cannot execute the binary file. I am not sure what the problem is, so here are a few details:

  1. I have added filtershift folder path to my path
  2. I have python installed (version 2.7.14)
  3. I have made a text file with the slice timings in seconds (64 slices in total):
    0
    0.927
    1.855
    0.802
    1.732
    0.679
    ...
  4. I have tried to run the simple command in bash:
    filtershift -i mcf_task-bandit-run1.nii.gz -o --timing=stimes-task.txt
    and I get:
/filtershift: cannot execute binary file

Any idea what the problem is? Here is the slice timing file and the EPIs: https://www.dropbox.com/sh/4tc9z5w8muhxljw/AACF1XfgH39ytYJa9W7nFd7qa?dl=0

Thank you

Flavia

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.