partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
NiftiSubjectsSet._load_image
Parameters ---------- file_path: str Path to the nifti file Returns ------- nipy.Image with a file_path member
boyle/nifti/sets.py
def _load_image(file_path): """ Parameters ---------- file_path: str Path to the nifti file Returns ------- nipy.Image with a file_path member """ if not os.path.exists(file_path): raise FileNotFound(file_path) try...
def _load_image(file_path): """ Parameters ---------- file_path: str Path to the nifti file Returns ------- nipy.Image with a file_path member """ if not os.path.exists(file_path): raise FileNotFound(file_path) try...
[ "Parameters", "----------", "file_path", ":", "str", "Path", "to", "the", "nifti", "file" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L381-L400
[ "def", "_load_image", "(", "file_path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "file_path", ")", ":", "raise", "FileNotFound", "(", "file_path", ")", "try", ":", "nii_img", "=", "load_nipy_img", "(", "file_path", ")", "nii_img", "....
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NiftiSubjectsSet._smooth_img
Parameters ---------- nii_img: nipy.Image smooth_fwhm: float Returns ------- smoothed nipy.Image
boyle/nifti/sets.py
def _smooth_img(nii_img, smooth_fwhm): """ Parameters ---------- nii_img: nipy.Image smooth_fwhm: float Returns ------- smoothed nipy.Image """ # delayed import because could not install nipy on Python 3 on OSX from nipy.algorit...
def _smooth_img(nii_img, smooth_fwhm): """ Parameters ---------- nii_img: nipy.Image smooth_fwhm: float Returns ------- smoothed nipy.Image """ # delayed import because could not install nipy on Python 3 on OSX from nipy.algorit...
[ "Parameters", "----------", "nii_img", ":", "nipy", ".", "Image" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L403-L422
[ "def", "_smooth_img", "(", "nii_img", ",", "smooth_fwhm", ")", ":", "# delayed import because could not install nipy on Python 3 on OSX", "from", "nipy", ".", "algorithms", ".", "kernel_smooth", "import", "LinearFilter", "if", "smooth_fwhm", "<=", "0", ":", "return", "n...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NiftiSubjectsSet.from_dict
Parameters ---------- subj_files: dict of str file_path -> int/str
boyle/nifti/sets.py
def from_dict(self, subj_files): """ Parameters ---------- subj_files: dict of str file_path -> int/str """ for group_label in subj_files: try: group_files = subj_files[group_label] self.items.extend([self._load_imag...
def from_dict(self, subj_files): """ Parameters ---------- subj_files: dict of str file_path -> int/str """ for group_label in subj_files: try: group_files = subj_files[group_label] self.items.extend([self._load_imag...
[ "Parameters", "----------", "subj_files", ":", "dict", "of", "str", "file_path", "-", ">", "int", "/", "str" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L424-L440
[ "def", "from_dict", "(", "self", ",", "subj_files", ")", ":", "for", "group_label", "in", "subj_files", ":", "try", ":", "group_files", "=", "subj_files", "[", "group_label", "]", "self", ".", "items", ".", "extend", "(", "[", "self", ".", "_load_image", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NiftiSubjectsSet.from_list
Parameters ---------- subj_files: list of str file_paths
boyle/nifti/sets.py
def from_list(self, subj_files): """ Parameters ---------- subj_files: list of str file_paths """ for sf in subj_files: try: nii_img = self._load_image(get_abspath(sf)) self.items.append(nii_img) except E...
def from_list(self, subj_files): """ Parameters ---------- subj_files: list of str file_paths """ for sf in subj_files: try: nii_img = self._load_image(get_abspath(sf)) self.items.append(nii_img) except E...
[ "Parameters", "----------", "subj_files", ":", "list", "of", "str", "file_paths" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L442-L454
[ "def", "from_list", "(", "self", ",", "subj_files", ")", ":", "for", "sf", "in", "subj_files", ":", "try", ":", "nii_img", "=", "self", ".", "_load_image", "(", "get_abspath", "(", "sf", ")", ")", "self", ".", "items", ".", "append", "(", "nii_img", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NiftiSubjectsSet.set_labels
Parameters ---------- subj_labels: list of int or str This list will be checked to have the same size as files list (self.items)
boyle/nifti/sets.py
def set_labels(self, subj_labels): """ Parameters ---------- subj_labels: list of int or str This list will be checked to have the same size as files list (self.items) """ if len(subj_labels) != self.n_subjs: raise ValueError('The numbe...
def set_labels(self, subj_labels): """ Parameters ---------- subj_labels: list of int or str This list will be checked to have the same size as files list (self.items) """ if len(subj_labels) != self.n_subjs: raise ValueError('The numbe...
[ "Parameters", "----------", "subj_labels", ":", "list", "of", "int", "or", "str", "This", "list", "will", "be", "checked", "to", "have", "the", "same", "size", "as", "files", "list", "(", "self", ".", "items", ")" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L469-L480
[ "def", "set_labels", "(", "self", ",", "subj_labels", ")", ":", "if", "len", "(", "subj_labels", ")", "!=", "self", ".", "n_subjs", ":", "raise", "ValueError", "(", "'The number of given labels is not the same as the number of subjects.'", ")", "self", ".", "labels"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NiftiSubjectsSet.to_matrix
Create a Numpy array with the data and return the relevant information (mask indices and volume shape). Parameters ---------- smooth_fwhm: int Integer indicating the size of the FWHM Gaussian smoothing kernel to smooth the subject volumes before creating the data matrix ...
boyle/nifti/sets.py
def to_matrix(self, smooth_fwhm=0, outdtype=None): """Create a Numpy array with the data and return the relevant information (mask indices and volume shape). Parameters ---------- smooth_fwhm: int Integer indicating the size of the FWHM Gaussian smoothing kernel ...
def to_matrix(self, smooth_fwhm=0, outdtype=None): """Create a Numpy array with the data and return the relevant information (mask indices and volume shape). Parameters ---------- smooth_fwhm: int Integer indicating the size of the FWHM Gaussian smoothing kernel ...
[ "Create", "a", "Numpy", "array", "with", "the", "data", "and", "return", "the", "relevant", "information", "(", "mask", "indices", "and", "volume", "shape", ")", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L482-L536
[ "def", "to_matrix", "(", "self", ",", "smooth_fwhm", "=", "0", ",", "outdtype", "=", "None", ")", ":", "vol", "=", "self", ".", "items", "[", "0", "]", ".", "get_data", "(", ")", "if", "not", "outdtype", ":", "outdtype", "=", "vol", ".", "dtype", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
die
Writes msg to stderr and exits with return code
boyle/commands.py
def die(msg, code=-1): """Writes msg to stderr and exits with return code""" sys.stderr.write(msg + "\n") sys.exit(code)
def die(msg, code=-1): """Writes msg to stderr and exits with return code""" sys.stderr.write(msg + "\n") sys.exit(code)
[ "Writes", "msg", "to", "stderr", "and", "exits", "with", "return", "code" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/commands.py#L68-L71
[ "def", "die", "(", "msg", ",", "code", "=", "-", "1", ")", ":", "sys", ".", "stderr", ".", "write", "(", "msg", "+", "\"\\n\"", ")", "sys", ".", "exit", "(", "code", ")" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
check_call
Calls the command Parameters ---------- cmd_args: list of str Command name to call and its arguments in a list. Returns ------- Command output
boyle/commands.py
def check_call(cmd_args): """ Calls the command Parameters ---------- cmd_args: list of str Command name to call and its arguments in a list. Returns ------- Command output """ p = subprocess.Popen(cmd_args, stdout=subprocess.PIPE) (output, err) = p.communicate() ...
def check_call(cmd_args): """ Calls the command Parameters ---------- cmd_args: list of str Command name to call and its arguments in a list. Returns ------- Command output """ p = subprocess.Popen(cmd_args, stdout=subprocess.PIPE) (output, err) = p.communicate() ...
[ "Calls", "the", "command" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/commands.py#L74-L89
[ "def", "check_call", "(", "cmd_args", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "cmd_args", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", "(", "output", ",", "err", ")", "=", "p", ".", "communicate", "(", ")", "return", "output" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
call_command
Call CLI command with arguments and returns its return value. Parameters ---------- cmd_name: str Command name or full path to the binary file. arg_strings: list of str Argument strings list. Returns ------- return_value Command return value.
boyle/commands.py
def call_command(cmd_name, args_strings): """Call CLI command with arguments and returns its return value. Parameters ---------- cmd_name: str Command name or full path to the binary file. arg_strings: list of str Argument strings list. Returns ------- return_value ...
def call_command(cmd_name, args_strings): """Call CLI command with arguments and returns its return value. Parameters ---------- cmd_name: str Command name or full path to the binary file. arg_strings: list of str Argument strings list. Returns ------- return_value ...
[ "Call", "CLI", "command", "with", "arguments", "and", "returns", "its", "return", "value", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/commands.py#L92-L124
[ "def", "call_command", "(", "cmd_name", ",", "args_strings", ")", ":", "if", "not", "op", ".", "isabs", "(", "cmd_name", ")", ":", "cmd_fullpath", "=", "which", "(", "cmd_name", ")", "else", ":", "cmd_fullpath", "=", "cmd_name", "try", ":", "cmd_line", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
condor_call
Tries to submit cmd to HTCondor, if it does not succeed, it will be called with subprocess.call. Parameters ---------- cmd: string Command to be submitted Returns -------
boyle/commands.py
def condor_call(cmd, shell=True): """ Tries to submit cmd to HTCondor, if it does not succeed, it will be called with subprocess.call. Parameters ---------- cmd: string Command to be submitted Returns ------- """ log.info(cmd) ret = condor_submit(cmd) if ret != ...
def condor_call(cmd, shell=True): """ Tries to submit cmd to HTCondor, if it does not succeed, it will be called with subprocess.call. Parameters ---------- cmd: string Command to be submitted Returns ------- """ log.info(cmd) ret = condor_submit(cmd) if ret != ...
[ "Tries", "to", "submit", "cmd", "to", "HTCondor", "if", "it", "does", "not", "succeed", "it", "will", "be", "called", "with", "subprocess", ".", "call", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/commands.py#L127-L143
[ "def", "condor_call", "(", "cmd", ",", "shell", "=", "True", ")", ":", "log", ".", "info", "(", "cmd", ")", "ret", "=", "condor_submit", "(", "cmd", ")", "if", "ret", "!=", "0", ":", "subprocess", ".", "call", "(", "cmd", ",", "shell", "=", "shel...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
condor_submit
Submits cmd to HTCondor queue Parameters ---------- cmd: string Command to be submitted Returns ------- int returncode value from calling the submission command.
boyle/commands.py
def condor_submit(cmd): """ Submits cmd to HTCondor queue Parameters ---------- cmd: string Command to be submitted Returns ------- int returncode value from calling the submission command. """ is_running = subprocess.call('condor_status', shell=True) == 0 i...
def condor_submit(cmd): """ Submits cmd to HTCondor queue Parameters ---------- cmd: string Command to be submitted Returns ------- int returncode value from calling the submission command. """ is_running = subprocess.call('condor_status', shell=True) == 0 i...
[ "Submits", "cmd", "to", "HTCondor", "queue" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/commands.py#L146-L169
[ "def", "condor_submit", "(", "cmd", ")", ":", "is_running", "=", "subprocess", ".", "call", "(", "'condor_status'", ",", "shell", "=", "True", ")", "==", "0", "if", "not", "is_running", ":", "raise", "CalledProcessError", "(", "'HTCondor is not running.'", ")"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
clean
Clean previously built package artifacts.
tasks.py
def clean(ctx): """Clean previously built package artifacts. """ ctx.run(f'python setup.py clean') dist = ROOT.joinpath('dist') print(f'removing {dist}') shutil.rmtree(str(dist))
def clean(ctx): """Clean previously built package artifacts. """ ctx.run(f'python setup.py clean') dist = ROOT.joinpath('dist') print(f'removing {dist}') shutil.rmtree(str(dist))
[ "Clean", "previously", "built", "package", "artifacts", "." ]
sarugaku/pipfile-cli
python
https://github.com/sarugaku/pipfile-cli/blob/ee9f8d1137e7423d2adc7e5748e8287b4402903d/tasks.py#L21-L27
[ "def", "clean", "(", "ctx", ")", ":", "ctx", ".", "run", "(", "f'python setup.py clean'", ")", "dist", "=", "ROOT", ".", "joinpath", "(", "'dist'", ")", "print", "(", "f'removing {dist}'", ")", "shutil", ".", "rmtree", "(", "str", "(", "dist", ")", ")"...
ee9f8d1137e7423d2adc7e5748e8287b4402903d
valid
upload
Upload the package to an index server. This implies cleaning and re-building the package. :param repo: Required. Name of the index server to upload to, as specifies in your .pypirc configuration file.
tasks.py
def upload(ctx, repo): """Upload the package to an index server. This implies cleaning and re-building the package. :param repo: Required. Name of the index server to upload to, as specifies in your .pypirc configuration file. """ artifacts = ' '.join( shlex.quote(str(n)) f...
def upload(ctx, repo): """Upload the package to an index server. This implies cleaning and re-building the package. :param repo: Required. Name of the index server to upload to, as specifies in your .pypirc configuration file. """ artifacts = ' '.join( shlex.quote(str(n)) f...
[ "Upload", "the", "package", "to", "an", "index", "server", "." ]
sarugaku/pipfile-cli
python
https://github.com/sarugaku/pipfile-cli/blob/ee9f8d1137e7423d2adc7e5748e8287b4402903d/tasks.py#L31-L43
[ "def", "upload", "(", "ctx", ",", "repo", ")", ":", "artifacts", "=", "' '", ".", "join", "(", "shlex", ".", "quote", "(", "str", "(", "n", ")", ")", "for", "n", "in", "ROOT", ".", "joinpath", "(", "'dist'", ")", ".", "glob", "(", "'pipfile[-_]cl...
ee9f8d1137e7423d2adc7e5748e8287b4402903d
valid
SFCommandLoader.load_command_table
Load all Service Fabric commands
rcctl/rcctl/commands.py
def load_command_table(self, args): #pylint: disable=too-many-statements """Load all Service Fabric commands""" # Need an empty client for the select and upload operations with CommandSuperGroup(__name__, self, 'rcctl.custom_cluster#{}') as super_group: ...
def load_command_table(self, args): #pylint: disable=too-many-statements """Load all Service Fabric commands""" # Need an empty client for the select and upload operations with CommandSuperGroup(__name__, self, 'rcctl.custom_cluster#{}') as super_group: ...
[ "Load", "all", "Service", "Fabric", "commands" ]
shalabhms/reliable-collections-cli
python
https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/commands.py#L33-L60
[ "def", "load_command_table", "(", "self", ",", "args", ")", ":", "#pylint: disable=too-many-statements", "# Need an empty client for the select and upload operations", "with", "CommandSuperGroup", "(", "__name__", ",", "self", ",", "'rcctl.custom_cluster#{}'", ")", "as", "sup...
195d69816fb5a6e1e9ab0ab66b606b1248b4780d
valid
open_volume_file
Open a volumetric file using the tools following the file extension. Parameters ---------- filepath: str Path to a volume file Returns ------- volume_data: np.ndarray Volume data pixdim: 1xN np.ndarray Vector with the description of the voxels physical size (usuall...
boyle/image/utils.py
def open_volume_file(filepath): """Open a volumetric file using the tools following the file extension. Parameters ---------- filepath: str Path to a volume file Returns ------- volume_data: np.ndarray Volume data pixdim: 1xN np.ndarray Vector with the descript...
def open_volume_file(filepath): """Open a volumetric file using the tools following the file extension. Parameters ---------- filepath: str Path to a volume file Returns ------- volume_data: np.ndarray Volume data pixdim: 1xN np.ndarray Vector with the descript...
[ "Open", "a", "volumetric", "file", "using", "the", "tools", "following", "the", "file", "extension", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/utils.py#L32-L93
[ "def", "open_volume_file", "(", "filepath", ")", ":", "# check if the file exists", "if", "not", "op", ".", "exists", "(", "filepath", ")", ":", "raise", "IOError", "(", "'Could not find file {}.'", ".", "format", "(", "filepath", ")", ")", "# define helper functi...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
_check_medimg
Check that image is a proper img. Turn filenames into objects. Parameters ---------- image: img-like object or str Can either be: - a file path to a medical image file, e.g. NifTI, .mhd/raw, .mha - any object with get_data() method and affine & header attributes, e.g., nibabel.Nifti...
boyle/image/utils.py
def _check_medimg(image, make_it_3d=True): """Check that image is a proper img. Turn filenames into objects. Parameters ---------- image: img-like object or str Can either be: - a file path to a medical image file, e.g. NifTI, .mhd/raw, .mha - any object with get_data() method a...
def _check_medimg(image, make_it_3d=True): """Check that image is a proper img. Turn filenames into objects. Parameters ---------- image: img-like object or str Can either be: - a file path to a medical image file, e.g. NifTI, .mhd/raw, .mha - any object with get_data() method a...
[ "Check", "that", "image", "is", "a", "proper", "img", ".", "Turn", "filenames", "into", "objects", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/utils.py#L96-L137
[ "def", "_check_medimg", "(", "image", ",", "make_it_3d", "=", "True", ")", ":", "if", "isinstance", "(", "image", ",", "string_types", ")", ":", "# a filename, load it", "img", "=", "open_volume_file", "(", "image", ")", "if", "make_it_3d", ":", "img", "=", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
rename_file_group_to_serial_nums
Will rename all files in file_lst to a padded serial number plus its extension :param file_lst: list of path.py paths
boyle/dicom/sets.py
def rename_file_group_to_serial_nums(file_lst): """Will rename all files in file_lst to a padded serial number plus its extension :param file_lst: list of path.py paths """ file_lst.sort() c = 1 for f in file_lst: dirname = get_abspath(f.dirname()) fdest = f.joinpath(dirname...
def rename_file_group_to_serial_nums(file_lst): """Will rename all files in file_lst to a padded serial number plus its extension :param file_lst: list of path.py paths """ file_lst.sort() c = 1 for f in file_lst: dirname = get_abspath(f.dirname()) fdest = f.joinpath(dirname...
[ "Will", "rename", "all", "files", "in", "file_lst", "to", "a", "padded", "serial", "number", "plus", "its", "extension" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L291-L305
[ "def", "rename_file_group_to_serial_nums", "(", "file_lst", ")", ":", "file_lst", ".", "sort", "(", ")", "c", "=", "1", "for", "f", "in", "file_lst", ":", "dirname", "=", "get_abspath", "(", "f", ".", "dirname", "(", ")", ")", "fdest", "=", "f", ".", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
DicomFileSet._store_dicom_paths
Search for dicoms in folders and save file paths into self.dicom_paths set. :param folders: str or list of str
boyle/dicom/sets.py
def _store_dicom_paths(self, folders): """Search for dicoms in folders and save file paths into self.dicom_paths set. :param folders: str or list of str """ if isinstance(folders, str): folders = [folders] for folder in folders: if not os.path.e...
def _store_dicom_paths(self, folders): """Search for dicoms in folders and save file paths into self.dicom_paths set. :param folders: str or list of str """ if isinstance(folders, str): folders = [folders] for folder in folders: if not os.path.e...
[ "Search", "for", "dicoms", "in", "folders", "and", "save", "file", "paths", "into", "self", ".", "dicom_paths", "set", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L29-L43
[ "def", "_store_dicom_paths", "(", "self", ",", "folders", ")", ":", "if", "isinstance", "(", "folders", ",", "str", ")", ":", "folders", "=", "[", "folders", "]", "for", "folder", "in", "folders", ":", "if", "not", "os", ".", "path", ".", "exists", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
DicomFileSet.from_set
Overwrites self.items with the given set of files. Will filter the fileset and keep only Dicom files. Parameters ---------- fileset: iterable of str Paths to files check_if_dicoms: bool Whether to check if the items in fileset are dicom file paths
boyle/dicom/sets.py
def from_set(self, fileset, check_if_dicoms=True): """Overwrites self.items with the given set of files. Will filter the fileset and keep only Dicom files. Parameters ---------- fileset: iterable of str Paths to files check_if_dicoms: bool Whether to che...
def from_set(self, fileset, check_if_dicoms=True): """Overwrites self.items with the given set of files. Will filter the fileset and keep only Dicom files. Parameters ---------- fileset: iterable of str Paths to files check_if_dicoms: bool Whether to che...
[ "Overwrites", "self", ".", "items", "with", "the", "given", "set", "of", "files", ".", "Will", "filter", "the", "fileset", "and", "keep", "only", "Dicom", "files", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L57-L75
[ "def", "from_set", "(", "self", ",", "fileset", ",", "check_if_dicoms", "=", "True", ")", ":", "if", "check_if_dicoms", ":", "self", ".", "items", "=", "[", "]", "for", "f", "in", "fileset", ":", "if", "is_dicom_file", "(", "f", ")", ":", "self", "."...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
DicomFileSet.update
Update this set with the union of itself and dicomset. Parameters ---------- dicomset: DicomFileSet
boyle/dicom/sets.py
def update(self, dicomset): """Update this set with the union of itself and dicomset. Parameters ---------- dicomset: DicomFileSet """ if not isinstance(dicomset, DicomFileSet): raise ValueError('Given dicomset is not a DicomFileSet.') self.items = l...
def update(self, dicomset): """Update this set with the union of itself and dicomset. Parameters ---------- dicomset: DicomFileSet """ if not isinstance(dicomset, DicomFileSet): raise ValueError('Given dicomset is not a DicomFileSet.') self.items = l...
[ "Update", "this", "set", "with", "the", "union", "of", "itself", "and", "dicomset", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L77-L87
[ "def", "update", "(", "self", ",", "dicomset", ")", ":", "if", "not", "isinstance", "(", "dicomset", ",", "DicomFileSet", ")", ":", "raise", "ValueError", "(", "'Given dicomset is not a DicomFileSet.'", ")", "self", ".", "items", "=", "list", "(", "set", "("...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
DicomFileSet.copy_files_to_other_folder
Copies all files within this set to the output_folder Parameters ---------- output_folder: str Path of the destination folder of the files rename_files: bool Whether or not rename the files to a sequential format mkdir: bool Whether to make the folder i...
boyle/dicom/sets.py
def copy_files_to_other_folder(self, output_folder, rename_files=True, mkdir=True, verbose=False): """ Copies all files within this set to the output_folder Parameters ---------- output_folder: str Path of the destination folder of the ...
def copy_files_to_other_folder(self, output_folder, rename_files=True, mkdir=True, verbose=False): """ Copies all files within this set to the output_folder Parameters ---------- output_folder: str Path of the destination folder of the ...
[ "Copies", "all", "files", "within", "this", "set", "to", "the", "output_folder" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L89-L126
[ "def", "copy_files_to_other_folder", "(", "self", ",", "output_folder", ",", "rename_files", "=", "True", ",", "mkdir", "=", "True", ",", "verbose", "=", "False", ")", ":", "import", "shutil", "if", "not", "os", ".", "path", ".", "exists", "(", "output_fol...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
DicomGenericSet.get_dcm_reader
Creates a lambda function to read DICOM files. If store_store_metadata is False, will only return the file path. Else if you give header_fields, will return only the set of of header_fields within a DicomFile object or the whole DICOM file if None. :return: function This...
boyle/dicom/sets.py
def get_dcm_reader(store_metadata=True, header_fields=None): """ Creates a lambda function to read DICOM files. If store_store_metadata is False, will only return the file path. Else if you give header_fields, will return only the set of of header_fields within a DicomFile object...
def get_dcm_reader(store_metadata=True, header_fields=None): """ Creates a lambda function to read DICOM files. If store_store_metadata is False, will only return the file path. Else if you give header_fields, will return only the set of of header_fields within a DicomFile object...
[ "Creates", "a", "lambda", "function", "to", "read", "DICOM", "files", ".", "If", "store_store_metadata", "is", "False", "will", "only", "return", "the", "file", "path", ".", "Else", "if", "you", "give", "header_fields", "will", "return", "only", "the", "set"...
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L151-L171
[ "def", "get_dcm_reader", "(", "store_metadata", "=", "True", ",", "header_fields", "=", "None", ")", ":", "if", "not", "store_metadata", ":", "return", "lambda", "fpath", ":", "fpath", "if", "header_fields", "is", "None", ":", "build_dcm", "=", "lambda", "fp...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
DicomGenericSet.scrape_all_files
Generator that yields one by one the return value for self.read_dcm for each file within this set
boyle/dicom/sets.py
def scrape_all_files(self): """ Generator that yields one by one the return value for self.read_dcm for each file within this set """ try: for dcmf in self.items: yield self.read_dcm(dcmf) except IOError as ioe: raise IOError('Error...
def scrape_all_files(self): """ Generator that yields one by one the return value for self.read_dcm for each file within this set """ try: for dcmf in self.items: yield self.read_dcm(dcmf) except IOError as ioe: raise IOError('Error...
[ "Generator", "that", "yields", "one", "by", "one", "the", "return", "value", "for", "self", ".", "read_dcm", "for", "each", "file", "within", "this", "set" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L173-L182
[ "def", "scrape_all_files", "(", "self", ")", ":", "try", ":", "for", "dcmf", "in", "self", ".", "items", ":", "yield", "self", ".", "read_dcm", "(", "dcmf", ")", "except", "IOError", "as", "ioe", ":", "raise", "IOError", "(", "'Error reading DICOM file: {}...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
get_unique_field_values
Return a set of unique field values from a list of DICOM files Parameters ---------- dcm_file_list: iterable of DICOM file paths field_name: str Name of the field from where to get each value Returns ------- Set of field values
boyle/dicom/utils.py
def get_unique_field_values(dcm_file_list, field_name): """Return a set of unique field values from a list of DICOM files Parameters ---------- dcm_file_list: iterable of DICOM file paths field_name: str Name of the field from where to get each value Returns ------- Set of field ...
def get_unique_field_values(dcm_file_list, field_name): """Return a set of unique field values from a list of DICOM files Parameters ---------- dcm_file_list: iterable of DICOM file paths field_name: str Name of the field from where to get each value Returns ------- Set of field ...
[ "Return", "a", "set", "of", "unique", "field", "values", "from", "a", "list", "of", "DICOM", "files" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/utils.py#L95-L114
[ "def", "get_unique_field_values", "(", "dcm_file_list", ",", "field_name", ")", ":", "field_values", "=", "set", "(", ")", "for", "dcm", "in", "dcm_file_list", ":", "field_values", ".", "add", "(", "str", "(", "DicomFile", "(", "dcm", ")", ".", "get_attribut...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
find_all_dicom_files
Returns a list of the dicom files within root_path Parameters ---------- root_path: str Path to the directory to be recursively searched for DICOM files. Returns ------- dicoms: set Set of DICOM absolute file paths
boyle/dicom/utils.py
def find_all_dicom_files(root_path): """ Returns a list of the dicom files within root_path Parameters ---------- root_path: str Path to the directory to be recursively searched for DICOM files. Returns ------- dicoms: set Set of DICOM absolute file paths """ dicoms = s...
def find_all_dicom_files(root_path): """ Returns a list of the dicom files within root_path Parameters ---------- root_path: str Path to the directory to be recursively searched for DICOM files. Returns ------- dicoms: set Set of DICOM absolute file paths """ dicoms = s...
[ "Returns", "a", "list", "of", "the", "dicom", "files", "within", "root_path" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/utils.py#L117-L140
[ "def", "find_all_dicom_files", "(", "root_path", ")", ":", "dicoms", "=", "set", "(", ")", "try", ":", "for", "fpath", "in", "get_all_files", "(", "root_path", ")", ":", "if", "is_dicom_file", "(", "fpath", ")", ":", "dicoms", ".", "add", "(", "fpath", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
is_dicom_file
Tries to read the file using dicom.read_file, if the file exists and dicom.read_file does not raise and Exception returns True. False otherwise. :param filepath: str Path to DICOM file :return: bool
boyle/dicom/utils.py
def is_dicom_file(filepath): """ Tries to read the file using dicom.read_file, if the file exists and dicom.read_file does not raise and Exception returns True. False otherwise. :param filepath: str Path to DICOM file :return: bool """ if not os.path.exists(filepath): rais...
def is_dicom_file(filepath): """ Tries to read the file using dicom.read_file, if the file exists and dicom.read_file does not raise and Exception returns True. False otherwise. :param filepath: str Path to DICOM file :return: bool """ if not os.path.exists(filepath): rais...
[ "Tries", "to", "read", "the", "file", "using", "dicom", ".", "read_file", "if", "the", "file", "exists", "and", "dicom", ".", "read_file", "does", "not", "raise", "and", "Exception", "returns", "True", ".", "False", "otherwise", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/utils.py#L143-L168
[ "def", "is_dicom_file", "(", "filepath", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "raise", "IOError", "(", "'File {} not found.'", ".", "format", "(", "filepath", ")", ")", "filename", "=", "os", ".", "path", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
group_dicom_files
Group in a dictionary all the DICOM files in dicom_paths separated by the given `hdr_field` tag value. Parameters ---------- dicom_paths: str Iterable of DICOM file paths. hdr_field: str Name of the DICOM tag whose values will be used as key for the group. Returns ------- ...
boyle/dicom/utils.py
def group_dicom_files(dicom_paths, hdr_field='PatientID'): """Group in a dictionary all the DICOM files in dicom_paths separated by the given `hdr_field` tag value. Parameters ---------- dicom_paths: str Iterable of DICOM file paths. hdr_field: str Name of the DICOM tag whose v...
def group_dicom_files(dicom_paths, hdr_field='PatientID'): """Group in a dictionary all the DICOM files in dicom_paths separated by the given `hdr_field` tag value. Parameters ---------- dicom_paths: str Iterable of DICOM file paths. hdr_field: str Name of the DICOM tag whose v...
[ "Group", "in", "a", "dictionary", "all", "the", "DICOM", "files", "in", "dicom_paths", "separated", "by", "the", "given", "hdr_field", "tag", "value", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/utils.py#L171-L196
[ "def", "group_dicom_files", "(", "dicom_paths", ",", "hdr_field", "=", "'PatientID'", ")", ":", "dicom_groups", "=", "defaultdict", "(", "list", ")", "try", ":", "for", "dcm", "in", "dicom_paths", ":", "hdr", "=", "dicom", ".", "read_file", "(", "dcm", ")"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
decompress
Decompress all *.dcm files recursively found in DICOM_DIR. This uses 'gdcmconv --raw'. It works when 'dcm2nii' shows the `Unsupported Transfer Syntax` error. This error is usually caused by lack of JPEG2000 support in dcm2nii compilation. Read more: http://www.nitrc.org/plugins/mwiki/index.php/dcm2...
boyle/dicom/utils.py
def decompress(input_dir, dcm_pattern='*.dcm'): """ Decompress all *.dcm files recursively found in DICOM_DIR. This uses 'gdcmconv --raw'. It works when 'dcm2nii' shows the `Unsupported Transfer Syntax` error. This error is usually caused by lack of JPEG2000 support in dcm2nii compilation. Read mor...
def decompress(input_dir, dcm_pattern='*.dcm'): """ Decompress all *.dcm files recursively found in DICOM_DIR. This uses 'gdcmconv --raw'. It works when 'dcm2nii' shows the `Unsupported Transfer Syntax` error. This error is usually caused by lack of JPEG2000 support in dcm2nii compilation. Read mor...
[ "Decompress", "all", "*", ".", "dcm", "files", "recursively", "found", "in", "DICOM_DIR", ".", "This", "uses", "gdcmconv", "--", "raw", ".", "It", "works", "when", "dcm2nii", "shows", "the", "Unsupported", "Transfer", "Syntax", "error", ".", "This", "error",...
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/utils.py#L199-L224
[ "def", "decompress", "(", "input_dir", ",", "dcm_pattern", "=", "'*.dcm'", ")", ":", "dcmfiles", "=", "sorted", "(", "recursive_glob", "(", "input_dir", ",", "dcm_pattern", ")", ")", "for", "dcm", "in", "dcmfiles", ":", "cmd", "=", "'gdcmconv --raw -i \"{0}\" ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
DicomFile.get_attributes
Return the attributes values from this DicomFile Parameters ---------- attributes: str or list of str DICOM field names default: str Default value if the attribute does not exist. Returns ------- Value of the field or list of values.
boyle/dicom/utils.py
def get_attributes(self, attributes, default=''): """Return the attributes values from this DicomFile Parameters ---------- attributes: str or list of str DICOM field names default: str Default value if the attribute does not exist. Returns --...
def get_attributes(self, attributes, default=''): """Return the attributes values from this DicomFile Parameters ---------- attributes: str or list of str DICOM field names default: str Default value if the attribute does not exist. Returns --...
[ "Return", "the", "attributes", "values", "from", "this", "DicomFile" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/utils.py#L63-L86
[ "def", "get_attributes", "(", "self", ",", "attributes", ",", "default", "=", "''", ")", ":", "if", "isinstance", "(", "attributes", ",", "str", ")", ":", "attributes", "=", "[", "attributes", "]", "attrs", "=", "[", "getattr", "(", "self", ",", "attr"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
merge_images
Concatenate `images` in the direction determined in `axis`. Parameters ---------- images: list of str or img-like object. See NeuroImage constructor docstring. axis: str 't' : concatenate images in time 'x' : concatenate images in the x direction 'y' : concatenate images in t...
boyle/nifti/utils.py
def merge_images(images, axis='t'): """ Concatenate `images` in the direction determined in `axis`. Parameters ---------- images: list of str or img-like object. See NeuroImage constructor docstring. axis: str 't' : concatenate images in time 'x' : concatenate images in the x d...
def merge_images(images, axis='t'): """ Concatenate `images` in the direction determined in `axis`. Parameters ---------- images: list of str or img-like object. See NeuroImage constructor docstring. axis: str 't' : concatenate images in time 'x' : concatenate images in the x d...
[ "Concatenate", "images", "in", "the", "direction", "determined", "in", "axis", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L25-L77
[ "def", "merge_images", "(", "images", ",", "axis", "=", "'t'", ")", ":", "# check if images is not empty", "if", "not", "images", ":", "return", "None", "# the given axis name to axis idx", "axis_dim", "=", "{", "'x'", ":", "0", ",", "'y'", ":", "1", ",", "'...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
nifti_out
Picks a function whose first argument is an `img`, processes its data and returns a numpy array. This decorator wraps this numpy array into a nibabel.Nifti1Image.
boyle/nifti/utils.py
def nifti_out(f): """ Picks a function whose first argument is an `img`, processes its data and returns a numpy array. This decorator wraps this numpy array into a nibabel.Nifti1Image.""" @wraps(f) def wrapped(*args, **kwargs): r = f(*args, **kwargs) img = read_img(args[0]) ...
def nifti_out(f): """ Picks a function whose first argument is an `img`, processes its data and returns a numpy array. This decorator wraps this numpy array into a nibabel.Nifti1Image.""" @wraps(f) def wrapped(*args, **kwargs): r = f(*args, **kwargs) img = read_img(args[0]) ...
[ "Picks", "a", "function", "whose", "first", "argument", "is", "an", "img", "processes", "its", "data", "and", "returns", "a", "numpy", "array", ".", "This", "decorator", "wraps", "this", "numpy", "array", "into", "a", "nibabel", ".", "Nifti1Image", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L80-L91
[ "def", "nifti_out", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "r", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "img", "=", "read_img", "(", "args", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
thr_img
Use the given magic function name `func` to threshold with value `thr` the data of `img` and return a new nibabel.Nifti1Image. Parameters ---------- img: img-like thr: float or int The threshold value. mode: str Choices: '+' for positive threshold, '+-' for pos...
boyle/nifti/utils.py
def thr_img(img, thr=2., mode='+'): """ Use the given magic function name `func` to threshold with value `thr` the data of `img` and return a new nibabel.Nifti1Image. Parameters ---------- img: img-like thr: float or int The threshold value. mode: str Choices: '+' for posit...
def thr_img(img, thr=2., mode='+'): """ Use the given magic function name `func` to threshold with value `thr` the data of `img` and return a new nibabel.Nifti1Image. Parameters ---------- img: img-like thr: float or int The threshold value. mode: str Choices: '+' for posit...
[ "Use", "the", "given", "magic", "function", "name", "func", "to", "threshold", "with", "value", "thr", "the", "data", "of", "img", "and", "return", "a", "new", "nibabel", ".", "Nifti1Image", ".", "Parameters", "----------", "img", ":", "img", "-", "like" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L95-L127
[ "def", "thr_img", "(", "img", ",", "thr", "=", "2.", ",", "mode", "=", "'+'", ")", ":", "vol", "=", "read_img", "(", "img", ")", ".", "get_data", "(", ")", "if", "mode", "==", "'+'", ":", "mask", "=", "vol", ">", "thr", "elif", "mode", "==", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
div_img
Pixelwise division or divide by a number
boyle/nifti/utils.py
def div_img(img1, div2): """ Pixelwise division or divide by a number """ if is_img(div2): return img1.get_data()/div2.get_data() elif isinstance(div2, (float, int)): return img1.get_data()/div2 else: raise NotImplementedError('Cannot divide {}({}) by ' ...
def div_img(img1, div2): """ Pixelwise division or divide by a number """ if is_img(div2): return img1.get_data()/div2.get_data() elif isinstance(div2, (float, int)): return img1.get_data()/div2 else: raise NotImplementedError('Cannot divide {}({}) by ' ...
[ "Pixelwise", "division", "or", "divide", "by", "a", "number" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L161-L172
[ "def", "div_img", "(", "img1", ",", "div2", ")", ":", "if", "is_img", "(", "div2", ")", ":", "return", "img1", ".", "get_data", "(", ")", "/", "div2", ".", "get_data", "(", ")", "elif", "isinstance", "(", "div2", ",", "(", "float", ",", "int", ")...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
apply_mask
Return the image with the given `mask` applied.
boyle/nifti/utils.py
def apply_mask(img, mask): """Return the image with the given `mask` applied.""" from .mask import apply_mask vol, _ = apply_mask(img, mask) return vector_to_volume(vol, read_img(mask).get_data().astype(bool))
def apply_mask(img, mask): """Return the image with the given `mask` applied.""" from .mask import apply_mask vol, _ = apply_mask(img, mask) return vector_to_volume(vol, read_img(mask).get_data().astype(bool))
[ "Return", "the", "image", "with", "the", "given", "mask", "applied", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L176-L181
[ "def", "apply_mask", "(", "img", ",", "mask", ")", ":", "from", ".", "mask", "import", "apply_mask", "vol", ",", "_", "=", "apply_mask", "(", "img", ",", "mask", ")", "return", "vector_to_volume", "(", "vol", ",", "read_img", "(", "mask", ")", ".", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
abs_img
Return an image with the binarised version of the data of `img`.
boyle/nifti/utils.py
def abs_img(img): """ Return an image with the binarised version of the data of `img`.""" bool_img = np.abs(read_img(img).get_data()) return bool_img.astype(int)
def abs_img(img): """ Return an image with the binarised version of the data of `img`.""" bool_img = np.abs(read_img(img).get_data()) return bool_img.astype(int)
[ "Return", "an", "image", "with", "the", "binarised", "version", "of", "the", "data", "of", "img", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L185-L188
[ "def", "abs_img", "(", "img", ")", ":", "bool_img", "=", "np", ".", "abs", "(", "read_img", "(", "img", ")", ".", "get_data", "(", ")", ")", "return", "bool_img", ".", "astype", "(", "int", ")" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
icc_img_to_zscore
Return a z-scored version of `icc`. This function is based on GIFT `icatb_convertImageToZScores` function.
boyle/nifti/utils.py
def icc_img_to_zscore(icc, center_image=False): """ Return a z-scored version of `icc`. This function is based on GIFT `icatb_convertImageToZScores` function. """ vol = read_img(icc).get_data() v2 = vol[vol != 0] if center_image: v2 = detrend(v2, axis=0) vstd = np.linalg.norm(v2, o...
def icc_img_to_zscore(icc, center_image=False): """ Return a z-scored version of `icc`. This function is based on GIFT `icatb_convertImageToZScores` function. """ vol = read_img(icc).get_data() v2 = vol[vol != 0] if center_image: v2 = detrend(v2, axis=0) vstd = np.linalg.norm(v2, o...
[ "Return", "a", "z", "-", "scored", "version", "of", "icc", ".", "This", "function", "is", "based", "on", "GIFT", "icatb_convertImageToZScores", "function", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L192-L207
[ "def", "icc_img_to_zscore", "(", "icc", ",", "center_image", "=", "False", ")", ":", "vol", "=", "read_img", "(", "icc", ")", ".", "get_data", "(", ")", "v2", "=", "vol", "[", "vol", "!=", "0", "]", "if", "center_image", ":", "v2", "=", "detrend", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
spatial_map
Return the thresholded z-scored `icc`.
boyle/nifti/utils.py
def spatial_map(icc, thr, mode='+'): """ Return the thresholded z-scored `icc`. """ return thr_img(icc_img_to_zscore(icc), thr=thr, mode=mode).get_data()
def spatial_map(icc, thr, mode='+'): """ Return the thresholded z-scored `icc`. """ return thr_img(icc_img_to_zscore(icc), thr=thr, mode=mode).get_data()
[ "Return", "the", "thresholded", "z", "-", "scored", "icc", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L211-L213
[ "def", "spatial_map", "(", "icc", ",", "thr", ",", "mode", "=", "'+'", ")", ":", "return", "thr_img", "(", "icc_img_to_zscore", "(", "icc", ")", ",", "thr", "=", "thr", ",", "mode", "=", "mode", ")", ".", "get_data", "(", ")" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
filter_icc
Threshold then mask an IC correlation map. Parameters ---------- icc: img-like The 'raw' ICC map. mask: img-like If not None. Will apply this masks in the end of the process. thr: float The threshold value. zscore: bool If True will calculate the z-score of the...
boyle/nifti/utils.py
def filter_icc(icc, mask=None, thr=2, zscore=True, mode="+"): """ Threshold then mask an IC correlation map. Parameters ---------- icc: img-like The 'raw' ICC map. mask: img-like If not None. Will apply this masks in the end of the process. thr: float The threshold valu...
def filter_icc(icc, mask=None, thr=2, zscore=True, mode="+"): """ Threshold then mask an IC correlation map. Parameters ---------- icc: img-like The 'raw' ICC map. mask: img-like If not None. Will apply this masks in the end of the process. thr: float The threshold valu...
[ "Threshold", "then", "mask", "an", "IC", "correlation", "map", ".", "Parameters", "----------", "icc", ":", "img", "-", "like", "The", "raw", "ICC", "map", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/utils.py#L216-L250
[ "def", "filter_icc", "(", "icc", ",", "mask", "=", "None", ",", "thr", "=", "2", ",", "zscore", "=", "True", ",", "mode", "=", "\"+\"", ")", ":", "if", "zscore", ":", "icc_filt", "=", "thr_img", "(", "icc_img_to_zscore", "(", "icc", ")", ",", "thr"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
check_mhd_img
Check that image is a proper img. Turn filenames into objects. Parameters ---------- image: img-like object or str Can either be: - a file path to a .mhd file. (if it is a .raw file, this won't work). - any object with get_data() and get_affine() methods, e.g., nibabel.Nifti1Image. ...
boyle/mhd/check.py
def check_mhd_img(image, make_it_3d=False): """Check that image is a proper img. Turn filenames into objects. Parameters ---------- image: img-like object or str Can either be: - a file path to a .mhd file. (if it is a .raw file, this won't work). - any object with get_data() an...
def check_mhd_img(image, make_it_3d=False): """Check that image is a proper img. Turn filenames into objects. Parameters ---------- image: img-like object or str Can either be: - a file path to a .mhd file. (if it is a .raw file, this won't work). - any object with get_data() an...
[ "Check", "that", "image", "is", "a", "proper", "img", ".", "Turn", "filenames", "into", "objects", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/check.py#L23-L66
[ "def", "check_mhd_img", "(", "image", ",", "make_it_3d", "=", "False", ")", ":", "if", "isinstance", "(", "image", ",", "string_types", ")", ":", "# a filename, load it", "if", "not", "op", ".", "exists", "(", "image", ")", ":", "raise", "FileNotFound", "(...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
_make_it_3d
Enforce that img is a 3D img-like object, if it is not, raise a TypeError. i.e., remove dimensions of size 1. Parameters ---------- img: numpy.ndarray Image data array Returns ------- 3D numpy ndarray object
boyle/mhd/check.py
def _make_it_3d(img): """Enforce that img is a 3D img-like object, if it is not, raise a TypeError. i.e., remove dimensions of size 1. Parameters ---------- img: numpy.ndarray Image data array Returns ------- 3D numpy ndarray object """ shape = img.shape if len(sha...
def _make_it_3d(img): """Enforce that img is a 3D img-like object, if it is not, raise a TypeError. i.e., remove dimensions of size 1. Parameters ---------- img: numpy.ndarray Image data array Returns ------- 3D numpy ndarray object """ shape = img.shape if len(sha...
[ "Enforce", "that", "img", "is", "a", "3D", "img", "-", "like", "object", "if", "it", "is", "not", "raise", "a", "TypeError", ".", "i", ".", "e", ".", "remove", "dimensions", "of", "size", "1", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/check.py#L69-L92
[ "def", "_make_it_3d", "(", "img", ")", ":", "shape", "=", "img", ".", "shape", "if", "len", "(", "shape", ")", "==", "3", ":", "return", "img", "elif", "len", "(", "shape", ")", "==", "4", "and", "shape", "[", "3", "]", "==", "1", ":", "# \"squ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
write_meta_header
Write the content of the `meta_dict` into `filename`. Parameters ---------- filename: str Path to the output file meta_dict: dict Dictionary with the fields of the metadata .mhd file
boyle/mhd/write.py
def write_meta_header(filename, meta_dict): """ Write the content of the `meta_dict` into `filename`. Parameters ---------- filename: str Path to the output file meta_dict: dict Dictionary with the fields of the metadata .mhd file """ header = '' # do not use tags = met...
def write_meta_header(filename, meta_dict): """ Write the content of the `meta_dict` into `filename`. Parameters ---------- filename: str Path to the output file meta_dict: dict Dictionary with the fields of the metadata .mhd file """ header = '' # do not use tags = met...
[ "Write", "the", "content", "of", "the", "meta_dict", "into", "filename", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/write.py#L25-L43
[ "def", "write_meta_header", "(", "filename", ",", "meta_dict", ")", ":", "header", "=", "''", "# do not use tags = meta_dict.keys() because the order of tags matters", "for", "tag", "in", "MHD_TAGS", ":", "if", "tag", "in", "meta_dict", ".", "keys", "(", ")", ":", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
dump_raw_data
Write the data into a raw format file. Big endian is always used. Parameters ---------- filename: str Path to the output file data: numpy.ndarray n-dimensional image data array.
boyle/mhd/write.py
def dump_raw_data(filename, data): """ Write the data into a raw format file. Big endian is always used. Parameters ---------- filename: str Path to the output file data: numpy.ndarray n-dimensional image data array. """ if data.ndim == 3: # Begin 3D fix dat...
def dump_raw_data(filename, data): """ Write the data into a raw format file. Big endian is always used. Parameters ---------- filename: str Path to the output file data: numpy.ndarray n-dimensional image data array. """ if data.ndim == 3: # Begin 3D fix dat...
[ "Write", "the", "data", "into", "a", "raw", "format", "file", ".", "Big", "endian", "is", "always", "used", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/write.py#L46-L70
[ "def", "dump_raw_data", "(", "filename", ",", "data", ")", ":", "if", "data", ".", "ndim", "==", "3", ":", "# Begin 3D fix", "data", "=", "data", ".", "reshape", "(", "[", "data", ".", "shape", "[", "0", "]", ",", "data", ".", "shape", "[", "1", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
write_mhd_file
Write the `data` and `meta_dict` in two files with names that use `filename` as a prefix. Parameters ---------- filename: str Path to the output file. This is going to be used as a preffix. Two files will be created, one with a '.mhd' extension and another with '.raw'. I...
boyle/mhd/write.py
def write_mhd_file(filename, data, shape=None, meta_dict=None): """ Write the `data` and `meta_dict` in two files with names that use `filename` as a prefix. Parameters ---------- filename: str Path to the output file. This is going to be used as a preffix. Two files will be...
def write_mhd_file(filename, data, shape=None, meta_dict=None): """ Write the `data` and `meta_dict` in two files with names that use `filename` as a prefix. Parameters ---------- filename: str Path to the output file. This is going to be used as a preffix. Two files will be...
[ "Write", "the", "data", "and", "meta_dict", "in", "two", "files", "with", "names", "that", "use", "filename", "as", "a", "prefix", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/write.py#L73-L147
[ "def", "write_mhd_file", "(", "filename", ",", "data", ",", "shape", "=", "None", ",", "meta_dict", "=", "None", ")", ":", "# check its extension", "ext", "=", "get_extension", "(", "filename", ")", "fname", "=", "op", ".", "basename", "(", "filename", ")"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
copy_mhd_and_raw
Copy .mhd and .raw files to dst. If dst is a folder, won't change the file, but if dst is another filepath, will modify the ElementDataFile field in the .mhd to point to the new renamed .raw file. Parameters ---------- src: str Path to the .mhd file to be copied dst: str P...
boyle/mhd/write.py
def copy_mhd_and_raw(src, dst): """Copy .mhd and .raw files to dst. If dst is a folder, won't change the file, but if dst is another filepath, will modify the ElementDataFile field in the .mhd to point to the new renamed .raw file. Parameters ---------- src: str Path to the .mhd fi...
def copy_mhd_and_raw(src, dst): """Copy .mhd and .raw files to dst. If dst is a folder, won't change the file, but if dst is another filepath, will modify the ElementDataFile field in the .mhd to point to the new renamed .raw file. Parameters ---------- src: str Path to the .mhd fi...
[ "Copy", ".", "mhd", "and", ".", "raw", "files", "to", "dst", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/write.py#L150-L217
[ "def", "copy_mhd_and_raw", "(", "src", ",", "dst", ")", ":", "# check if src exists", "if", "not", "op", ".", "exists", "(", "src", ")", ":", "raise", "IOError", "(", "'Could not find file {}.'", ".", "format", "(", "src", ")", ")", "# check its extension", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
sav_to_pandas_rpy2
SPSS .sav files to Pandas DataFrame through Rpy2 :param input_file: string :return:
boyle/storage.py
def sav_to_pandas_rpy2(input_file): """ SPSS .sav files to Pandas DataFrame through Rpy2 :param input_file: string :return: """ import pandas.rpy.common as com w = com.robj.r('foreign::read.spss("%s", to.data.frame=TRUE)' % input_file) return com.convert_robj(w)
def sav_to_pandas_rpy2(input_file): """ SPSS .sav files to Pandas DataFrame through Rpy2 :param input_file: string :return: """ import pandas.rpy.common as com w = com.robj.r('foreign::read.spss("%s", to.data.frame=TRUE)' % input_file) return com.convert_robj(w)
[ "SPSS", ".", "sav", "files", "to", "Pandas", "DataFrame", "through", "Rpy2" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/storage.py#L23-L34
[ "def", "sav_to_pandas_rpy2", "(", "input_file", ")", ":", "import", "pandas", ".", "rpy", ".", "common", "as", "com", "w", "=", "com", ".", "robj", ".", "r", "(", "'foreign::read.spss(\"%s\", to.data.frame=TRUE)'", "%", "input_file", ")", "return", "com", ".",...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
sav_to_pandas_savreader
SPSS .sav files to Pandas DataFrame through savreader module :param input_file: string :return:
boyle/storage.py
def sav_to_pandas_savreader(input_file): """ SPSS .sav files to Pandas DataFrame through savreader module :param input_file: string :return: """ from savReaderWriter import SavReader lines = [] with SavReader(input_file, returnHeader=True) as reader: header = next(reader) ...
def sav_to_pandas_savreader(input_file): """ SPSS .sav files to Pandas DataFrame through savreader module :param input_file: string :return: """ from savReaderWriter import SavReader lines = [] with SavReader(input_file, returnHeader=True) as reader: header = next(reader) ...
[ "SPSS", ".", "sav", "files", "to", "Pandas", "DataFrame", "through", "savreader", "module" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/storage.py#L37-L52
[ "def", "sav_to_pandas_savreader", "(", "input_file", ")", ":", "from", "savReaderWriter", "import", "SavReader", "lines", "=", "[", "]", "with", "SavReader", "(", "input_file", ",", "returnHeader", "=", "True", ")", "as", "reader", ":", "header", "=", "next", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
ExportData.save_variables
Save given variables in a file. Valid extensions: '.pyshelf' or '.shelf' (Python shelve) '.mat' (Matlab archive), '.hdf5' or '.h5' (HDF5 file) Parameters ---------- filename: str Output file path. variables: dict ...
boyle/storage.py
def save_variables(filename, variables): """Save given variables in a file. Valid extensions: '.pyshelf' or '.shelf' (Python shelve) '.mat' (Matlab archive), '.hdf5' or '.h5' (HDF5 file) Parameters ---------- filename: str ...
def save_variables(filename, variables): """Save given variables in a file. Valid extensions: '.pyshelf' or '.shelf' (Python shelve) '.mat' (Matlab archive), '.hdf5' or '.h5' (HDF5 file) Parameters ---------- filename: str ...
[ "Save", "given", "variables", "in", "a", "file", ".", "Valid", "extensions", ":", ".", "pyshelf", "or", ".", "shelf", "(", "Python", "shelve", ")", ".", "mat", "(", "Matlab", "archive", ")", ".", "hdf5", "or", ".", "h5", "(", "HDF5", "file", ")" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/storage.py#L118-L155
[ "def", "save_variables", "(", "filename", ",", "variables", ")", ":", "ext", "=", "get_extension", "(", "filename", ")", ".", "lower", "(", ")", "out_exts", "=", "{", "'.pyshelf'", ",", "'.shelf'", ",", "'.mat'", ",", "'.hdf5'", ",", "'.h5'", "}", "outpu...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
ExportData.save_varlist
Valid extensions '.pyshelf', '.mat', '.hdf5' or '.h5' @param filename: string @param varnames: list of strings Names of the variables @param varlist: list of objects The objects to be saved
boyle/storage.py
def save_varlist(filename, varnames, varlist): """ Valid extensions '.pyshelf', '.mat', '.hdf5' or '.h5' @param filename: string @param varnames: list of strings Names of the variables @param varlist: list of objects The objects to be saved """ ...
def save_varlist(filename, varnames, varlist): """ Valid extensions '.pyshelf', '.mat', '.hdf5' or '.h5' @param filename: string @param varnames: list of strings Names of the variables @param varlist: list of objects The objects to be saved """ ...
[ "Valid", "extensions", ".", "pyshelf", ".", "mat", ".", "hdf5", "or", ".", "h5" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/storage.py#L158-L174
[ "def", "save_varlist", "(", "filename", ",", "varnames", ",", "varlist", ")", ":", "variables", "=", "{", "}", "for", "i", ",", "vn", "in", "enumerate", "(", "varnames", ")", ":", "variables", "[", "vn", "]", "=", "varlist", "[", "i", "]", "ExportDat...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
cli
Create CLI environment
rcctl/rcctl/entry.py
def cli(): """Create CLI environment""" return VersionedCLI(cli_name=SF_CLI_NAME, config_dir=SF_CLI_CONFIG_DIR, config_env_var_prefix=SF_CLI_ENV_VAR_PREFIX, commands_loader_cls=SFCommandLoader, help_cls=SFCommandHelp...
def cli(): """Create CLI environment""" return VersionedCLI(cli_name=SF_CLI_NAME, config_dir=SF_CLI_CONFIG_DIR, config_env_var_prefix=SF_CLI_ENV_VAR_PREFIX, commands_loader_cls=SFCommandLoader, help_cls=SFCommandHelp...
[ "Create", "CLI", "environment" ]
shalabhms/reliable-collections-cli
python
https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/entry.py#L10-L16
[ "def", "cli", "(", ")", ":", "return", "VersionedCLI", "(", "cli_name", "=", "SF_CLI_NAME", ",", "config_dir", "=", "SF_CLI_CONFIG_DIR", ",", "config_env_var_prefix", "=", "SF_CLI_ENV_VAR_PREFIX", ",", "commands_loader_cls", "=", "SFCommandLoader", ",", "help_cls", ...
195d69816fb5a6e1e9ab0ab66b606b1248b4780d
valid
drain_rois
Find all the ROIs in img and returns a similar volume with the ROIs emptied, keeping only their border voxels. This is useful for DTI tractography. Parameters ---------- img: img-like object or str Can either be: - a file path to a Nifti image - any object with get_data() a...
boyle/nifti/roi.py
def drain_rois(img): """Find all the ROIs in img and returns a similar volume with the ROIs emptied, keeping only their border voxels. This is useful for DTI tractography. Parameters ---------- img: img-like object or str Can either be: - a file path to a Nifti image - ...
def drain_rois(img): """Find all the ROIs in img and returns a similar volume with the ROIs emptied, keeping only their border voxels. This is useful for DTI tractography. Parameters ---------- img: img-like object or str Can either be: - a file path to a Nifti image - ...
[ "Find", "all", "the", "ROIs", "in", "img", "and", "returns", "a", "similar", "volume", "with", "the", "ROIs", "emptied", "keeping", "only", "their", "border", "voxels", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L23-L60
[ "def", "drain_rois", "(", "img", ")", ":", "img_data", "=", "get_img_data", "(", "img", ")", "out", "=", "np", ".", "zeros", "(", "img_data", ".", "shape", ",", "dtype", "=", "img_data", ".", "dtype", ")", "krn_dim", "=", "[", "3", "]", "*", "img_d...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
pick_rois
Return the `rois_img` only with the ROI values from `roi_values`. Parameters ---------- rois_img: niimg-like roi_values: list of int or float The list of values from rois_img. bg_val: int or float The background value of `rois_img`. Returns ------- subset_rois_img: nib...
boyle/nifti/roi.py
def pick_rois(rois_img, roi_values, bg_val=0): """ Return the `rois_img` only with the ROI values from `roi_values`. Parameters ---------- rois_img: niimg-like roi_values: list of int or float The list of values from rois_img. bg_val: int or float The background value of `rois_...
def pick_rois(rois_img, roi_values, bg_val=0): """ Return the `rois_img` only with the ROI values from `roi_values`. Parameters ---------- rois_img: niimg-like roi_values: list of int or float The list of values from rois_img. bg_val: int or float The background value of `rois_...
[ "Return", "the", "rois_img", "only", "with", "the", "ROI", "values", "from", "roi_values", ".", "Parameters", "----------", "rois_img", ":", "niimg", "-", "like" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L63-L90
[ "def", "pick_rois", "(", "rois_img", ",", "roi_values", ",", "bg_val", "=", "0", ")", ":", "img", "=", "read_img", "(", "rois_img", ")", "img_data", "=", "img", ".", "get_data", "(", ")", "if", "bg_val", "==", "0", ":", "out", "=", "np", ".", "zero...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
largest_connected_component
Return the largest connected component of a 3D array. Parameters ----------- volume: numpy.array 3D boolean array. Returns -------- volume: numpy.array 3D boolean array with only one connected component.
boyle/nifti/roi.py
def largest_connected_component(volume): """Return the largest connected component of a 3D array. Parameters ----------- volume: numpy.array 3D boolean array. Returns -------- volume: numpy.array 3D boolean array with only one connected component. """ # We use asarr...
def largest_connected_component(volume): """Return the largest connected component of a 3D array. Parameters ----------- volume: numpy.array 3D boolean array. Returns -------- volume: numpy.array 3D boolean array with only one connected component. """ # We use asarr...
[ "Return", "the", "largest", "connected", "component", "of", "a", "3D", "array", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L93-L118
[ "def", "largest_connected_component", "(", "volume", ")", ":", "# We use asarray to be able to work with masked arrays.", "volume", "=", "np", ".", "asarray", "(", "volume", ")", "labels", ",", "num_labels", "=", "scn", ".", "label", "(", "volume", ")", "if", "not...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
large_clusters_mask
Return as mask for `volume` that includes only areas where the connected components have a size bigger than `min_cluster_size` in number of voxels. Parameters ----------- volume: numpy.array 3D boolean array. min_cluster_size: int Minimum size in voxels that the connected compo...
boyle/nifti/roi.py
def large_clusters_mask(volume, min_cluster_size): """ Return as mask for `volume` that includes only areas where the connected components have a size bigger than `min_cluster_size` in number of voxels. Parameters ----------- volume: numpy.array 3D boolean array. min_cluster_size: ...
def large_clusters_mask(volume, min_cluster_size): """ Return as mask for `volume` that includes only areas where the connected components have a size bigger than `min_cluster_size` in number of voxels. Parameters ----------- volume: numpy.array 3D boolean array. min_cluster_size: ...
[ "Return", "as", "mask", "for", "volume", "that", "includes", "only", "areas", "where", "the", "connected", "components", "have", "a", "size", "bigger", "than", "min_cluster_size", "in", "number", "of", "voxels", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L121-L149
[ "def", "large_clusters_mask", "(", "volume", ",", "min_cluster_size", ")", ":", "labels", ",", "num_labels", "=", "scn", ".", "label", "(", "volume", ")", "labels_to_keep", "=", "set", "(", "[", "i", "for", "i", "in", "range", "(", "num_labels", ")", "if...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
create_rois_mask
Look for the files in filelist containing the names in roislist, these files will be opened, binarised and merged in one mask. Parameters ---------- roislist: list of strings Names of the ROIs, which will have to be in the names of the files in filelist. filelist: list of strings L...
boyle/nifti/roi.py
def create_rois_mask(roislist, filelist): """Look for the files in filelist containing the names in roislist, these files will be opened, binarised and merged in one mask. Parameters ---------- roislist: list of strings Names of the ROIs, which will have to be in the names of the files in f...
def create_rois_mask(roislist, filelist): """Look for the files in filelist containing the names in roislist, these files will be opened, binarised and merged in one mask. Parameters ---------- roislist: list of strings Names of the ROIs, which will have to be in the names of the files in f...
[ "Look", "for", "the", "files", "in", "filelist", "containing", "the", "names", "in", "roislist", "these", "files", "will", "be", "opened", "binarised", "and", "merged", "in", "one", "mask", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L152-L179
[ "def", "create_rois_mask", "(", "roislist", ",", "filelist", ")", ":", "roifiles", "=", "[", "]", "for", "roi", "in", "roislist", ":", "try", ":", "roi_file", "=", "search_list", "(", "roi", ",", "filelist", ")", "[", "0", "]", "except", "Exception", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
get_unique_nonzeros
Return a sorted list of the non-zero unique values of arr. Parameters ---------- arr: numpy.ndarray The data array Returns ------- list of items of arr.
boyle/nifti/roi.py
def get_unique_nonzeros(arr): """ Return a sorted list of the non-zero unique values of arr. Parameters ---------- arr: numpy.ndarray The data array Returns ------- list of items of arr. """ rois = np.unique(arr) rois = rois[np.nonzero(rois)] rois.sort() return...
def get_unique_nonzeros(arr): """ Return a sorted list of the non-zero unique values of arr. Parameters ---------- arr: numpy.ndarray The data array Returns ------- list of items of arr. """ rois = np.unique(arr) rois = rois[np.nonzero(rois)] rois.sort() return...
[ "Return", "a", "sorted", "list", "of", "the", "non", "-", "zero", "unique", "values", "of", "arr", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L182-L198
[ "def", "get_unique_nonzeros", "(", "arr", ")", ":", "rois", "=", "np", ".", "unique", "(", "arr", ")", "rois", "=", "rois", "[", "np", ".", "nonzero", "(", "rois", ")", "]", "rois", ".", "sort", "(", ")", "return", "rois" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
get_rois_centers_of_mass
Get the center of mass for each ROI in the given volume. Parameters ---------- vol: numpy ndarray Volume with different values for each ROI. Returns ------- OrderedDict Each entry in the dict has the ROI value as key and the center_of_mass coordinate as value.
boyle/nifti/roi.py
def get_rois_centers_of_mass(vol): """Get the center of mass for each ROI in the given volume. Parameters ---------- vol: numpy ndarray Volume with different values for each ROI. Returns ------- OrderedDict Each entry in the dict has the ROI value as key and the center_of_m...
def get_rois_centers_of_mass(vol): """Get the center of mass for each ROI in the given volume. Parameters ---------- vol: numpy ndarray Volume with different values for each ROI. Returns ------- OrderedDict Each entry in the dict has the ROI value as key and the center_of_m...
[ "Get", "the", "center", "of", "mass", "for", "each", "ROI", "in", "the", "given", "volume", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L228-L250
[ "def", "get_rois_centers_of_mass", "(", "vol", ")", ":", "from", "scipy", ".", "ndimage", ".", "measurements", "import", "center_of_mass", "roisvals", "=", "np", ".", "unique", "(", "vol", ")", "roisvals", "=", "roisvals", "[", "roisvals", "!=", "0", "]", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
partition_timeseries
Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. The outdict indicates whether you want a dictionary for each set of timeseries keyed by the ROI value or a list of timeseries sets. If True and roi_img is not None will ret...
boyle/nifti/roi.py
def partition_timeseries(image, roi_img, mask_img=None, zeroe=True, roi_values=None, outdict=False): """Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. The outdict indicates whether you want a dictionary for each set of ...
def partition_timeseries(image, roi_img, mask_img=None, zeroe=True, roi_values=None, outdict=False): """Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. The outdict indicates whether you want a dictionary for each set of ...
[ "Partition", "the", "timeseries", "in", "tsvol", "according", "to", "the", "ROIs", "in", "roivol", ".", "If", "a", "mask", "is", "given", "will", "use", "it", "to", "exclude", "any", "voxel", "outside", "of", "it", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L253-L326
[ "def", "partition_timeseries", "(", "image", ",", "roi_img", ",", "mask_img", "=", "None", ",", "zeroe", "=", "True", ",", "roi_values", "=", "None", ",", "outdict", "=", "False", ")", ":", "img", "=", "read_img", "(", "image", ")", "rois", "=", "read_...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
_partition_data
Extracts the values in `datavol` that are in the ROI with value `roivalue` in `roivol`. The ROI can be masked by `maskvol`. Parameters ---------- datavol: numpy.ndarray 4D timeseries volume or a 3D volume to be partitioned roivol: numpy.ndarray 3D ROIs volume roivalue: int or ...
boyle/nifti/roi.py
def _partition_data(datavol, roivol, roivalue, maskvol=None, zeroe=True): """ Extracts the values in `datavol` that are in the ROI with value `roivalue` in `roivol`. The ROI can be masked by `maskvol`. Parameters ---------- datavol: numpy.ndarray 4D timeseries volume or a 3D volume to be pa...
def _partition_data(datavol, roivol, roivalue, maskvol=None, zeroe=True): """ Extracts the values in `datavol` that are in the ROI with value `roivalue` in `roivol`. The ROI can be masked by `maskvol`. Parameters ---------- datavol: numpy.ndarray 4D timeseries volume or a 3D volume to be pa...
[ "Extracts", "the", "values", "in", "datavol", "that", "are", "in", "the", "ROI", "with", "value", "roivalue", "in", "roivol", ".", "The", "ROI", "can", "be", "masked", "by", "maskvol", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L350-L394
[ "def", "_partition_data", "(", "datavol", ",", "roivol", ",", "roivalue", ",", "maskvol", "=", "None", ",", "zeroe", "=", "True", ")", ":", "if", "maskvol", "is", "not", "None", ":", "# get all masked time series within this roi r", "indices", "=", "(", "roivo...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
_extract_timeseries_dict
Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. Parameters ---------- tsvol: numpy.ndarray 4D timeseries volume or a 3D volume to be partitioned roivol: numpy.ndarray 3D ROIs volume maskvol:...
boyle/nifti/roi.py
def _extract_timeseries_dict(tsvol, roivol, maskvol=None, roi_values=None, zeroe=True): """Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. Parameters ---------- tsvol: numpy.ndarray 4D timeseries volume o...
def _extract_timeseries_dict(tsvol, roivol, maskvol=None, roi_values=None, zeroe=True): """Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. Parameters ---------- tsvol: numpy.ndarray 4D timeseries volume o...
[ "Partition", "the", "timeseries", "in", "tsvol", "according", "to", "the", "ROIs", "in", "roivol", ".", "If", "a", "mask", "is", "given", "will", "use", "it", "to", "exclude", "any", "voxel", "outside", "of", "it", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L397-L439
[ "def", "_extract_timeseries_dict", "(", "tsvol", ",", "roivol", ",", "maskvol", "=", "None", ",", "roi_values", "=", "None", ",", "zeroe", "=", "True", ")", ":", "_check_for_partition", "(", "tsvol", ",", "roivol", ",", "maskvol", ")", "# get unique values of ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
_extract_timeseries_list
Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. Parameters ---------- tsvol: numpy.ndarray 4D timeseries volume or a 3D volume to be partitioned roivol: numpy.ndarray 3D ROIs volume maskvol:...
boyle/nifti/roi.py
def _extract_timeseries_list(tsvol, roivol, maskvol=None, roi_values=None, zeroe=True): """Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. Parameters ---------- tsvol: numpy.ndarray 4D timeseries volume o...
def _extract_timeseries_list(tsvol, roivol, maskvol=None, roi_values=None, zeroe=True): """Partition the timeseries in tsvol according to the ROIs in roivol. If a mask is given, will use it to exclude any voxel outside of it. Parameters ---------- tsvol: numpy.ndarray 4D timeseries volume o...
[ "Partition", "the", "timeseries", "in", "tsvol", "according", "to", "the", "ROIs", "in", "roivol", ".", "If", "a", "mask", "is", "given", "will", "use", "it", "to", "exclude", "any", "voxel", "outside", "of", "it", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L442-L483
[ "def", "_extract_timeseries_list", "(", "tsvol", ",", "roivol", ",", "maskvol", "=", "None", ",", "roi_values", "=", "None", ",", "zeroe", "=", "True", ")", ":", "_check_for_partition", "(", "tsvol", ",", "roivol", ",", "maskvol", ")", "if", "roi_values", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
get_3D_from_4D
Pick one 3D volume from a 4D nifti image file Parameters ---------- image: img-like object or str Volume defining different ROIs. Can either be: - a file path to a Nifti image - any object with get_data() and get_affine() methods, e.g., nibabel.Nifti1Image. If niimg ...
boyle/nifti/roi.py
def get_3D_from_4D(image, vol_idx=0): """Pick one 3D volume from a 4D nifti image file Parameters ---------- image: img-like object or str Volume defining different ROIs. Can either be: - a file path to a Nifti image - any object with get_data() and get_affine() methods,...
def get_3D_from_4D(image, vol_idx=0): """Pick one 3D volume from a 4D nifti image file Parameters ---------- image: img-like object or str Volume defining different ROIs. Can either be: - a file path to a Nifti image - any object with get_data() and get_affine() methods,...
[ "Pick", "one", "3D", "volume", "from", "a", "4D", "nifti", "image", "file" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/roi.py#L486-L523
[ "def", "get_3D_from_4D", "(", "image", ",", "vol_idx", "=", "0", ")", ":", "img", "=", "check_img", "(", "image", ")", "hdr", ",", "aff", "=", "get_img_info", "(", "img", ")", "if", "len", "(", "img", ".", "shape", ")", "!=", "4", ":", "raise", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
HdfDataBuffer.create_hdf_file
:return: h5py DataSet
boyle/databuffer.py
def create_hdf_file(self): """ :return: h5py DataSet """ mode = 'w' if not self._overwrite and os.path.exists(self._fname): mode = 'a' self._hdf_file = h5py.File(self._fname, mode) if self._hdf_basepath == '/': self._group = self._hdf_fil...
def create_hdf_file(self): """ :return: h5py DataSet """ mode = 'w' if not self._overwrite and os.path.exists(self._fname): mode = 'a' self._hdf_file = h5py.File(self._fname, mode) if self._hdf_basepath == '/': self._group = self._hdf_fil...
[ ":", "return", ":", "h5py", "DataSet" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L99-L112
[ "def", "create_hdf_file", "(", "self", ")", ":", "mode", "=", "'w'", "if", "not", "self", ".", "_overwrite", "and", "os", ".", "path", ".", "exists", "(", "self", ".", "_fname", ")", ":", "mode", "=", "'a'", "self", ".", "_hdf_file", "=", "h5py", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
HdfDataBuffer.get_dataset
Returns a h5py dataset given its registered name. :param ds_name: string Name of the dataset to be returned. :return:
boyle/databuffer.py
def get_dataset(self, ds_name, mode='r'): """ Returns a h5py dataset given its registered name. :param ds_name: string Name of the dataset to be returned. :return: """ if ds_name in self._datasets: return self._datasets[ds_name] else: ...
def get_dataset(self, ds_name, mode='r'): """ Returns a h5py dataset given its registered name. :param ds_name: string Name of the dataset to be returned. :return: """ if ds_name in self._datasets: return self._datasets[ds_name] else: ...
[ "Returns", "a", "h5py", "dataset", "given", "its", "registered", "name", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L114-L126
[ "def", "get_dataset", "(", "self", ",", "ds_name", ",", "mode", "=", "'r'", ")", ":", "if", "ds_name", "in", "self", ".", "_datasets", ":", "return", "self", ".", "_datasets", "[", "ds_name", "]", "else", ":", "return", "self", ".", "create_empty_dataset...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
HdfDataBuffer.create_empty_dataset
Creates a Dataset with unknown size. Resize it before using. :param ds_name: string :param dtype: dtype Datatype of the dataset :return: h5py DataSet
boyle/databuffer.py
def create_empty_dataset(self, ds_name, dtype=np.float32): """ Creates a Dataset with unknown size. Resize it before using. :param ds_name: string :param dtype: dtype Datatype of the dataset :return: h5py DataSet """ if ds_name in self._datasets...
def create_empty_dataset(self, ds_name, dtype=np.float32): """ Creates a Dataset with unknown size. Resize it before using. :param ds_name: string :param dtype: dtype Datatype of the dataset :return: h5py DataSet """ if ds_name in self._datasets...
[ "Creates", "a", "Dataset", "with", "unknown", "size", ".", "Resize", "it", "before", "using", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L128-L147
[ "def", "create_empty_dataset", "(", "self", ",", "ds_name", ",", "dtype", "=", "np", ".", "float32", ")", ":", "if", "ds_name", "in", "self", ".", "_datasets", ":", "return", "self", ".", "_datasets", "[", "ds_name", "]", "ds", "=", "self", ".", "_grou...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
HdfDataBuffer.create_dataset
Saves a Numpy array in a dataset in the HDF file, registers it as ds_name and returns the h5py dataset. :param ds_name: string Registration name of the dataset to be registered. :param data: Numpy ndarray :param dtype: dtype Datatype of the dataset :return: h5...
boyle/databuffer.py
def create_dataset(self, ds_name, data, attrs=None, dtype=None): """ Saves a Numpy array in a dataset in the HDF file, registers it as ds_name and returns the h5py dataset. :param ds_name: string Registration name of the dataset to be registered. :param data: Numpy ndar...
def create_dataset(self, ds_name, data, attrs=None, dtype=None): """ Saves a Numpy array in a dataset in the HDF file, registers it as ds_name and returns the h5py dataset. :param ds_name: string Registration name of the dataset to be registered. :param data: Numpy ndar...
[ "Saves", "a", "Numpy", "array", "in", "a", "dataset", "in", "the", "HDF", "file", "registers", "it", "as", "ds_name", "and", "returns", "the", "h5py", "dataset", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L149-L183
[ "def", "create_dataset", "(", "self", ",", "ds_name", ",", "data", ",", "attrs", "=", "None", ",", "dtype", "=", "None", ")", ":", "if", "ds_name", "in", "self", ".", "_datasets", ":", "ds", "=", "self", ".", "_datasets", "[", "ds_name", "]", "if", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
HdfDataBuffer.save
See create_dataset.
boyle/databuffer.py
def save(self, ds_name, data, dtype=None): """ See create_dataset. """ return self.create_dataset(ds_name, data, dtype)
def save(self, ds_name, data, dtype=None): """ See create_dataset. """ return self.create_dataset(ds_name, data, dtype)
[ "See", "create_dataset", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L185-L189
[ "def", "save", "(", "self", ",", "ds_name", ",", "data", ",", "dtype", "=", "None", ")", ":", "return", "self", ".", "create_dataset", "(", "ds_name", ",", "data", ",", "dtype", ")" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NumpyHDFStore._fill_missing_values
Will get the names of the index colums of df, obtain their ranges from range_values dict and return a reindexed version of df with the given range values. :param df: pandas DataFrame :param range_values: dict or array-like Must contain for each index column of df an entry with ...
boyle/databuffer.py
def _fill_missing_values(df, range_values, fill_value=0, fill_method=None): """ Will get the names of the index colums of df, obtain their ranges from range_values dict and return a reindexed version of df with the given range values. :param df: pandas DataFrame :param ...
def _fill_missing_values(df, range_values, fill_value=0, fill_method=None): """ Will get the names of the index colums of df, obtain their ranges from range_values dict and return a reindexed version of df with the given range values. :param df: pandas DataFrame :param ...
[ "Will", "get", "the", "names", "of", "the", "index", "colums", "of", "df", "obtain", "their", "ranges", "from", "range_values", "dict", "and", "return", "a", "reindexed", "version", "of", "df", "with", "the", "given", "range", "values", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L225-L263
[ "def", "_fill_missing_values", "(", "df", ",", "range_values", ",", "fill_value", "=", "0", ",", "fill_method", "=", "None", ")", ":", "idx_colnames", "=", "df", ".", "index", ".", "names", "idx_colranges", "=", "[", "range_values", "[", "x", "]", "for", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NumpyHDFStore.get
Retrieve pandas object or group of Numpy ndarrays stored in file Parameters ---------- key : object Returns ------- obj : type of object stored in file
boyle/databuffer.py
def get(self, key): """ Retrieve pandas object or group of Numpy ndarrays stored in file Parameters ---------- key : object Returns ------- obj : type of object stored in file """ node = self.get_node(key) if node is None:...
def get(self, key): """ Retrieve pandas object or group of Numpy ndarrays stored in file Parameters ---------- key : object Returns ------- obj : type of object stored in file """ node = self.get_node(key) if node is None:...
[ "Retrieve", "pandas", "object", "or", "group", "of", "Numpy", "ndarrays", "stored", "in", "file" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L265-L286
[ "def", "get", "(", "self", ",", "key", ")", ":", "node", "=", "self", ".", "get_node", "(", "key", ")", "if", "node", "is", "None", ":", "raise", "KeyError", "(", "'No object named %s in the file'", "%", "key", ")", "if", "hasattr", "(", "node", ",", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NumpyHDFStore.put
Store object in HDFStore Parameters ---------- key : str value : {Series, DataFrame, Panel, Numpy ndarray} format : 'fixed(f)|table(t)', default is 'fixed' fixed(f) : Fixed format Fast writing/reading. Not-appendable, nor searchable tab...
boyle/databuffer.py
def put(self, key, value, attrs=None, format=None, append=False, **kwargs): """ Store object in HDFStore Parameters ---------- key : str value : {Series, DataFrame, Panel, Numpy ndarray} format : 'fixed(f)|table(t)', default is 'fixed' fixed(f) : Fi...
def put(self, key, value, attrs=None, format=None, append=False, **kwargs): """ Store object in HDFStore Parameters ---------- key : str value : {Series, DataFrame, Panel, Numpy ndarray} format : 'fixed(f)|table(t)', default is 'fixed' fixed(f) : Fi...
[ "Store", "object", "in", "HDFStore" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L288-L348
[ "def", "put", "(", "self", ",", "key", ",", "value", ",", "attrs", "=", "None", ",", "format", "=", "None", ",", "append", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "value", ",", "np", ".", "ndarray", ")", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NumpyHDFStore._push_dfblock
:param key: string :param df: pandas Dataframe :param ds_name: string
boyle/databuffer.py
def _push_dfblock(self, key, df, ds_name, range_values): """ :param key: string :param df: pandas Dataframe :param ds_name: string """ #create numpy array and put into hdf_file vals_colranges = [range_values[x] for x in df.index.names] nu_shape = [len(x) f...
def _push_dfblock(self, key, df, ds_name, range_values): """ :param key: string :param df: pandas Dataframe :param ds_name: string """ #create numpy array and put into hdf_file vals_colranges = [range_values[x] for x in df.index.names] nu_shape = [len(x) f...
[ ":", "param", "key", ":", "string", ":", "param", "df", ":", "pandas", "Dataframe", ":", "param", "ds_name", ":", "string" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L350-L362
[ "def", "_push_dfblock", "(", "self", ",", "key", ",", "df", ",", "ds_name", ",", "range_values", ")", ":", "#create numpy array and put into hdf_file", "vals_colranges", "=", "[", "range_values", "[", "x", "]", "for", "x", "in", "df", ".", "index", ".", "nam...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
NumpyHDFStore.put_df_as_ndarray
Returns a PyTables HDF Array from df in the shape given by its index columns range values. :param key: string object :param df: pandas DataFrame :param range_values: dict or array-like Must contain for each index column of df an entry with all the values within the range of th...
boyle/databuffer.py
def put_df_as_ndarray(self, key, df, range_values, loop_multiindex=False, unstack=False, fill_value=0, fill_method=None): """Returns a PyTables HDF Array from df in the shape given by its index columns range values. :param key: string object :param df: pandas DataFram...
def put_df_as_ndarray(self, key, df, range_values, loop_multiindex=False, unstack=False, fill_value=0, fill_method=None): """Returns a PyTables HDF Array from df in the shape given by its index columns range values. :param key: string object :param df: pandas DataFram...
[ "Returns", "a", "PyTables", "HDF", "Array", "from", "df", "in", "the", "shape", "given", "by", "its", "index", "columns", "range", "values", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/databuffer.py#L364-L449
[ "def", "put_df_as_ndarray", "(", "self", ",", "key", ",", "df", ",", "range_values", ",", "loop_multiindex", "=", "False", ",", "unstack", "=", "False", ",", "fill_value", "=", "0", ",", "fill_method", "=", "None", ")", ":", "idx_colnames", "=", "df", "....
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
ImageContainer.get_data
Get the data in the image. If save_copy is True, will perform a deep copy of the data and return it. Parameters ---------- smoothed: (optional) bool If True and self._smooth_fwhm > 0 will smooth the data before masking. masked: (optional) bool If True a...
boyle/image/base.py
def get_data(self, safe_copy=False): """Get the data in the image. If save_copy is True, will perform a deep copy of the data and return it. Parameters ---------- smoothed: (optional) bool If True and self._smooth_fwhm > 0 will smooth the data before masking. ...
def get_data(self, safe_copy=False): """Get the data in the image. If save_copy is True, will perform a deep copy of the data and return it. Parameters ---------- smoothed: (optional) bool If True and self._smooth_fwhm > 0 will smooth the data before masking. ...
[ "Get", "the", "data", "in", "the", "image", ".", "If", "save_copy", "is", "True", "will", "perform", "a", "deep", "copy", "of", "the", "data", "and", "return", "it", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L100-L123
[ "def", "get_data", "(", "self", ",", "safe_copy", "=", "False", ")", ":", "if", "safe_copy", ":", "data", "=", "get_data", "(", "self", ".", "img", ")", "else", ":", "data", "=", "self", ".", "img", ".", "get_data", "(", "caching", "=", "self", "."...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.smooth_fwhm
Set a smoothing Gaussian kernel given its FWHM in mm.
boyle/image/base.py
def smooth_fwhm(self, fwhm): """ Set a smoothing Gaussian kernel given its FWHM in mm. """ if fwhm != self._smooth_fwhm: self._is_data_smooth = False self._smooth_fwhm = fwhm
def smooth_fwhm(self, fwhm): """ Set a smoothing Gaussian kernel given its FWHM in mm. """ if fwhm != self._smooth_fwhm: self._is_data_smooth = False self._smooth_fwhm = fwhm
[ "Set", "a", "smoothing", "Gaussian", "kernel", "given", "its", "FWHM", "in", "mm", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L178-L182
[ "def", "smooth_fwhm", "(", "self", ",", "fwhm", ")", ":", "if", "fwhm", "!=", "self", ".", "_smooth_fwhm", ":", "self", ".", "_is_data_smooth", "=", "False", "self", ".", "_smooth_fwhm", "=", "fwhm" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.get_data
Get the data in the image. If save_copy is True, will perform a deep copy of the data and return it. Parameters ---------- smoothed: (optional) bool If True and self._smooth_fwhm > 0 will smooth the data before masking. masked: (optional) bool If True a...
boyle/image/base.py
def get_data(self, smoothed=True, masked=True, safe_copy=False): """Get the data in the image. If save_copy is True, will perform a deep copy of the data and return it. Parameters ---------- smoothed: (optional) bool If True and self._smooth_fwhm > 0 will smooth the...
def get_data(self, smoothed=True, masked=True, safe_copy=False): """Get the data in the image. If save_copy is True, will perform a deep copy of the data and return it. Parameters ---------- smoothed: (optional) bool If True and self._smooth_fwhm > 0 will smooth the...
[ "Get", "the", "data", "in", "the", "image", ".", "If", "save_copy", "is", "True", "will", "perform", "a", "deep", "copy", "of", "the", "data", "and", "return", "it", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L198-L248
[ "def", "get_data", "(", "self", ",", "smoothed", "=", "True", ",", "masked", "=", "True", ",", "safe_copy", "=", "False", ")", ":", "if", "not", "safe_copy", "and", "smoothed", "==", "self", ".", "_is_data_smooth", "and", "masked", "==", "self", ".", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.apply_mask
First set_mask and the get_masked_data. Parameters ---------- mask_img: nifti-like image, NeuroImage or str 3D mask array: True where a voxel should be used. Can either be: - a file path to a Nifti image - any object with get_data() and get_affin...
boyle/image/base.py
def apply_mask(self, mask_img): """First set_mask and the get_masked_data. Parameters ---------- mask_img: nifti-like image, NeuroImage or str 3D mask array: True where a voxel should be used. Can either be: - a file path to a Nifti image ...
def apply_mask(self, mask_img): """First set_mask and the get_masked_data. Parameters ---------- mask_img: nifti-like image, NeuroImage or str 3D mask array: True where a voxel should be used. Can either be: - a file path to a Nifti image ...
[ "First", "set_mask", "and", "the", "get_masked_data", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L259-L278
[ "def", "apply_mask", "(", "self", ",", "mask_img", ")", ":", "self", ".", "set_mask", "(", "mask_img", ")", "return", "self", ".", "get_data", "(", "masked", "=", "True", ",", "smoothed", "=", "True", ",", "safe_copy", "=", "True", ")" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.set_mask
Sets a mask img to this. So every operation to self, this mask will be taken into account. Parameters ---------- mask_img: nifti-like image, NeuroImage or str 3D mask array: True where a voxel should be used. Can either be: - a file path to a Nifti image ...
boyle/image/base.py
def set_mask(self, mask_img): """Sets a mask img to this. So every operation to self, this mask will be taken into account. Parameters ---------- mask_img: nifti-like image, NeuroImage or str 3D mask array: True where a voxel should be used. Can either be: ...
def set_mask(self, mask_img): """Sets a mask img to this. So every operation to self, this mask will be taken into account. Parameters ---------- mask_img: nifti-like image, NeuroImage or str 3D mask array: True where a voxel should be used. Can either be: ...
[ "Sets", "a", "mask", "img", "to", "this", ".", "So", "every", "operation", "to", "self", "this", "mask", "will", "be", "taken", "into", "account", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L280-L304
[ "def", "set_mask", "(", "self", ",", "mask_img", ")", ":", "mask", "=", "load_mask", "(", "mask_img", ",", "allow_empty", "=", "True", ")", "check_img_compatibility", "(", "self", ".", "img", ",", "mask", ",", "only_check_3d", "=", "True", ")", "# this wil...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage._mask_data
Return the data masked with self.mask Parameters ---------- data: np.ndarray Returns ------- masked np.ndarray Raises ------ ValueError if the data and mask dimensions are not compatible. Other exceptions related to numpy computations.
boyle/image/base.py
def _mask_data(self, data): """Return the data masked with self.mask Parameters ---------- data: np.ndarray Returns ------- masked np.ndarray Raises ------ ValueError if the data and mask dimensions are not compatible. Other exce...
def _mask_data(self, data): """Return the data masked with self.mask Parameters ---------- data: np.ndarray Returns ------- masked np.ndarray Raises ------ ValueError if the data and mask dimensions are not compatible. Other exce...
[ "Return", "the", "data", "masked", "with", "self", ".", "mask" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L306-L330
[ "def", "_mask_data", "(", "self", ",", "data", ")", ":", "self", ".", "_check_for_mask", "(", ")", "msk_data", "=", "self", ".", "mask", ".", "get_data", "(", ")", "if", "self", ".", "ndim", "==", "3", ":", "return", "data", "[", "msk_data", "]", "...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.apply_smoothing
Set self._smooth_fwhm and then smooths the data. See boyle.nifti.smooth.smooth_imgs. Returns ------- the smoothed data deepcopied.
boyle/image/base.py
def apply_smoothing(self, smooth_fwhm): """Set self._smooth_fwhm and then smooths the data. See boyle.nifti.smooth.smooth_imgs. Returns ------- the smoothed data deepcopied. """ if smooth_fwhm <= 0: return old_smooth_fwhm = self._smooth_fw...
def apply_smoothing(self, smooth_fwhm): """Set self._smooth_fwhm and then smooths the data. See boyle.nifti.smooth.smooth_imgs. Returns ------- the smoothed data deepcopied. """ if smooth_fwhm <= 0: return old_smooth_fwhm = self._smooth_fw...
[ "Set", "self", ".", "_smooth_fwhm", "and", "then", "smooths", "the", "data", ".", "See", "boyle", ".", "nifti", ".", "smooth", ".", "smooth_imgs", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L332-L353
[ "def", "apply_smoothing", "(", "self", ",", "smooth_fwhm", ")", ":", "if", "smooth_fwhm", "<=", "0", ":", "return", "old_smooth_fwhm", "=", "self", ".", "_smooth_fwhm", "self", ".", "_smooth_fwhm", "=", "smooth_fwhm", "try", ":", "data", "=", "self", ".", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.mask_and_flatten
Return a vector of the masked data. Returns ------- np.ndarray, tuple of indices (np.ndarray), tuple of the mask shape
boyle/image/base.py
def mask_and_flatten(self): """Return a vector of the masked data. Returns ------- np.ndarray, tuple of indices (np.ndarray), tuple of the mask shape """ self._check_for_mask() return self.get_data(smoothed=True, masked=True, safe_copy=False)[self.get_mask_indic...
def mask_and_flatten(self): """Return a vector of the masked data. Returns ------- np.ndarray, tuple of indices (np.ndarray), tuple of the mask shape """ self._check_for_mask() return self.get_data(smoothed=True, masked=True, safe_copy=False)[self.get_mask_indic...
[ "Return", "a", "vector", "of", "the", "masked", "data", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L355-L365
[ "def", "mask_and_flatten", "(", "self", ")", ":", "self", ".", "_check_for_mask", "(", ")", "return", "self", ".", "get_data", "(", "smoothed", "=", "True", ",", "masked", "=", "True", ",", "safe_copy", "=", "False", ")", "[", "self", ".", "get_mask_indi...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.unmask
Use self.mask to reshape arr and self.img to get an affine and header to create a new self.img using the data in arr. If self.has_mask() is False, will return the same arr.
boyle/image/base.py
def unmask(self, arr): """Use self.mask to reshape arr and self.img to get an affine and header to create a new self.img using the data in arr. If self.has_mask() is False, will return the same arr. """ self._check_for_mask() if 1 > arr.ndim > 2: raise ValueE...
def unmask(self, arr): """Use self.mask to reshape arr and self.img to get an affine and header to create a new self.img using the data in arr. If self.has_mask() is False, will return the same arr. """ self._check_for_mask() if 1 > arr.ndim > 2: raise ValueE...
[ "Use", "self", ".", "mask", "to", "reshape", "arr", "and", "self", ".", "img", "to", "get", "an", "affine", "and", "header", "to", "create", "a", "new", "self", ".", "img", "using", "the", "data", "in", "arr", ".", "If", "self", ".", "has_mask", "(...
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L367-L382
[ "def", "unmask", "(", "self", ",", "arr", ")", ":", "self", ".", "_check_for_mask", "(", ")", "if", "1", ">", "arr", ".", "ndim", ">", "2", ":", "raise", "ValueError", "(", "'The given array has {} dimensions while my mask has {}. '", "'Masked data must be 1D or 2...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
MedicalImage.to_file
Save this object instance in outpath. Parameters ---------- outpath: str Output file path
boyle/image/base.py
def to_file(self, outpath): """Save this object instance in outpath. Parameters ---------- outpath: str Output file path """ if not self.has_mask() and not self.is_smoothed(): save_niigz(outpath, self.img) else: save_niigz(outp...
def to_file(self, outpath): """Save this object instance in outpath. Parameters ---------- outpath: str Output file path """ if not self.has_mask() and not self.is_smoothed(): save_niigz(outpath, self.img) else: save_niigz(outp...
[ "Save", "this", "object", "instance", "in", "outpath", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/image/base.py#L384-L396
[ "def", "to_file", "(", "self", ",", "outpath", ")", ":", "if", "not", "self", ".", "has_mask", "(", ")", "and", "not", "self", ".", "is_smoothed", "(", ")", ":", "save_niigz", "(", "outpath", ",", "self", ".", "img", ")", "else", ":", "save_niigz", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
setup_logging
Setup logging configuration.
boyle/utils/logger.py
def setup_logging(log_config_file=op.join(op.dirname(__file__), 'logger.yml'), log_default_level=LOG_LEVEL, env_key=MODULE_NAME.upper() + '_LOG_CFG'): """Setup logging configuration.""" path = log_config_file value = os.getenv(env_key, None) if value: path = v...
def setup_logging(log_config_file=op.join(op.dirname(__file__), 'logger.yml'), log_default_level=LOG_LEVEL, env_key=MODULE_NAME.upper() + '_LOG_CFG'): """Setup logging configuration.""" path = log_config_file value = os.getenv(env_key, None) if value: path = v...
[ "Setup", "logging", "configuration", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/logger.py#L13-L31
[ "def", "setup_logging", "(", "log_config_file", "=", "op", ".", "join", "(", "op", ".", "dirname", "(", "__file__", ")", ",", "'logger.yml'", ")", ",", "log_default_level", "=", "LOG_LEVEL", ",", "env_key", "=", "MODULE_NAME", ".", "upper", "(", ")", "+", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
_read_meta_header
Return a dictionary of meta data from meta header file. Parameters ---------- filename: str Path to a .mhd file Returns ------- meta_dict: dict A dictionary with the .mhd header content.
boyle/mhd/read.py
def _read_meta_header(filename): """Return a dictionary of meta data from meta header file. Parameters ---------- filename: str Path to a .mhd file Returns ------- meta_dict: dict A dictionary with the .mhd header content. """ fileIN = open(filename, 'r') line ...
def _read_meta_header(filename): """Return a dictionary of meta data from meta header file. Parameters ---------- filename: str Path to a .mhd file Returns ------- meta_dict: dict A dictionary with the .mhd header content. """ fileIN = open(filename, 'r') line ...
[ "Return", "a", "dictionary", "of", "meta", "data", "from", "meta", "header", "file", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/read.py#L20-L50
[ "def", "_read_meta_header", "(", "filename", ")", ":", "fileIN", "=", "open", "(", "filename", ",", "'r'", ")", "line", "=", "fileIN", ".", "readline", "(", ")", "meta_dict", "=", "{", "}", "tag_flag", "=", "[", "False", "]", "*", "len", "(", "MHD_TA...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
load_raw_data_with_mhd
Return a dictionary of meta data from meta header file. Parameters ---------- filename: str Path to a .mhd file Returns ------- data: numpy.ndarray n-dimensional image data array. meta_dict: dict A dictionary with the .mhd header content.
boyle/mhd/read.py
def load_raw_data_with_mhd(filename): """Return a dictionary of meta data from meta header file. Parameters ---------- filename: str Path to a .mhd file Returns ------- data: numpy.ndarray n-dimensional image data array. meta_dict: dict A dictionary with the .m...
def load_raw_data_with_mhd(filename): """Return a dictionary of meta data from meta header file. Parameters ---------- filename: str Path to a .mhd file Returns ------- data: numpy.ndarray n-dimensional image data array. meta_dict: dict A dictionary with the .m...
[ "Return", "a", "dictionary", "of", "meta", "data", "from", "meta", "header", "file", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/read.py#L53-L98
[ "def", "load_raw_data_with_mhd", "(", "filename", ")", ":", "meta_dict", "=", "_read_meta_header", "(", "filename", ")", "dim", "=", "int", "(", "meta_dict", "[", "'NDims'", "]", ")", "assert", "(", "meta_dict", "[", "'ElementType'", "]", "in", "MHD_TO_NUMPY_T...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
get_3D_from_4D
Return a 3D volume from a 4D nifti image file Parameters ---------- filename: str Path to the 4D .mhd file vol_idx: int Index of the 3D volume to be extracted from the 4D volume. Returns ------- vol, hdr The data array and the new 3D image header.
boyle/mhd/read.py
def get_3D_from_4D(filename, vol_idx=0): """Return a 3D volume from a 4D nifti image file Parameters ---------- filename: str Path to the 4D .mhd file vol_idx: int Index of the 3D volume to be extracted from the 4D volume. Returns ------- vol, hdr The data arra...
def get_3D_from_4D(filename, vol_idx=0): """Return a 3D volume from a 4D nifti image file Parameters ---------- filename: str Path to the 4D .mhd file vol_idx: int Index of the 3D volume to be extracted from the 4D volume. Returns ------- vol, hdr The data arra...
[ "Return", "a", "3D", "volume", "from", "a", "4D", "nifti", "image", "file" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/mhd/read.py#L101-L137
[ "def", "get_3D_from_4D", "(", "filename", ",", "vol_idx", "=", "0", ")", ":", "def", "remove_4th_element_from_hdr_string", "(", "hdr", ",", "fieldname", ")", ":", "if", "fieldname", "in", "hdr", ":", "hdr", "[", "fieldname", "]", "=", "' '", ".", "join", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
_safe_cache
A wrapper for mem.cache that flushes the cache if the version number of nibabel has changed.
boyle/utils/cache_mixin.py
def _safe_cache(memory, func, **kwargs): """ A wrapper for mem.cache that flushes the cache if the version number of nibabel has changed. """ cachedir = memory.cachedir if cachedir is None or cachedir in __CACHE_CHECKED: return memory.cache(func, **kwargs) version_file = os.path.jo...
def _safe_cache(memory, func, **kwargs): """ A wrapper for mem.cache that flushes the cache if the version number of nibabel has changed. """ cachedir = memory.cachedir if cachedir is None or cachedir in __CACHE_CHECKED: return memory.cache(func, **kwargs) version_file = os.path.jo...
[ "A", "wrapper", "for", "mem", ".", "cache", "that", "flushes", "the", "cache", "if", "the", "version", "number", "of", "nibabel", "has", "changed", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/cache_mixin.py#L31-L90
[ "def", "_safe_cache", "(", "memory", ",", "func", ",", "*", "*", "kwargs", ")", ":", "cachedir", "=", "memory", ".", "cachedir", "if", "cachedir", "is", "None", "or", "cachedir", "in", "__CACHE_CHECKED", ":", "return", "memory", ".", "cache", "(", "func"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
cache
Return a joblib.Memory object. The memory_level determines the level above which the wrapped function output is cached. By specifying a numeric value for this level, the user can to control the amount of cache memory used. This function will cache the function call or not depending on the cache lev...
boyle/utils/cache_mixin.py
def cache(func, memory, func_memory_level=None, memory_level=None, **kwargs): """ Return a joblib.Memory object. The memory_level determines the level above which the wrapped function output is cached. By specifying a numeric value for this level, the user can to control the amount of cache m...
def cache(func, memory, func_memory_level=None, memory_level=None, **kwargs): """ Return a joblib.Memory object. The memory_level determines the level above which the wrapped function output is cached. By specifying a numeric value for this level, the user can to control the amount of cache m...
[ "Return", "a", "joblib", ".", "Memory", "object", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/cache_mixin.py#L93-L160
[ "def", "cache", "(", "func", ",", "memory", ",", "func_memory_level", "=", "None", ",", "memory_level", "=", "None", ",", "*", "*", "kwargs", ")", ":", "verbose", "=", "kwargs", ".", "get", "(", "'verbose'", ",", "0", ")", "# memory_level and func_memory_l...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
CacheMixin._cache
Return a joblib.Memory object. The memory_level determines the level above which the wrapped function output is cached. By specifying a numeric value for this level, the user can to control the amount of cache memory used. This function will cache the function call or not depend...
boyle/utils/cache_mixin.py
def _cache(self, func, func_memory_level=1, **kwargs): """ Return a joblib.Memory object. The memory_level determines the level above which the wrapped function output is cached. By specifying a numeric value for this level, the user can to control the amount of cache memory use...
def _cache(self, func, func_memory_level=1, **kwargs): """ Return a joblib.Memory object. The memory_level determines the level above which the wrapped function output is cached. By specifying a numeric value for this level, the user can to control the amount of cache memory use...
[ "Return", "a", "joblib", ".", "Memory", "object", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/cache_mixin.py#L174-L223
[ "def", "_cache", "(", "self", ",", "func", ",", "func_memory_level", "=", "1", ",", "*", "*", "kwargs", ")", ":", "verbose", "=", "getattr", "(", "self", ",", "'verbose'", ",", "0", ")", "# Creates attributes if they don't exist", "# This is to make creating the...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
save_niigz
Saves a volume into a Nifti (.nii.gz) file. Parameters ---------- vol: Numpy 3D or 4D array Volume with the data to be saved. file_path: string Output file name path affine: (optional) 4x4 Numpy array Array with the affine transform of the file. This is needed if v...
boyle/nifti/storage.py
def save_niigz(filepath, vol, header=None, affine=None): """Saves a volume into a Nifti (.nii.gz) file. Parameters ---------- vol: Numpy 3D or 4D array Volume with the data to be saved. file_path: string Output file name path affine: (optional) 4x4 Numpy array Array wi...
def save_niigz(filepath, vol, header=None, affine=None): """Saves a volume into a Nifti (.nii.gz) file. Parameters ---------- vol: Numpy 3D or 4D array Volume with the data to be saved. file_path: string Output file name path affine: (optional) 4x4 Numpy array Array wi...
[ "Saves", "a", "volume", "into", "a", "Nifti", "(", ".", "nii", ".", "gz", ")", "file", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L24-L75
[ "def", "save_niigz", "(", "filepath", ",", "vol", ",", "header", "=", "None", ",", "affine", "=", "None", ")", ":", "# delayed import because could not install nipy on Python 3 on OSX", "we_have_nipy", "=", "False", "try", ":", "import", "nipy", ".", "core", ".", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
spatialimg_to_hdfgroup
Saves a Nifti1Image into an HDF5 group. Parameters ---------- h5group: h5py Group Output HDF5 file path spatial_img: nibabel SpatialImage Image to be saved h5path: str HDF5 group path where the image data will be saved. Datasets will be created inside the given gro...
boyle/nifti/storage.py
def spatialimg_to_hdfgroup(h5group, spatial_img): """Saves a Nifti1Image into an HDF5 group. Parameters ---------- h5group: h5py Group Output HDF5 file path spatial_img: nibabel SpatialImage Image to be saved h5path: str HDF5 group path where the image data will be sav...
def spatialimg_to_hdfgroup(h5group, spatial_img): """Saves a Nifti1Image into an HDF5 group. Parameters ---------- h5group: h5py Group Output HDF5 file path spatial_img: nibabel SpatialImage Image to be saved h5path: str HDF5 group path where the image data will be sav...
[ "Saves", "a", "Nifti1Image", "into", "an", "HDF5", "group", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L78-L108
[ "def", "spatialimg_to_hdfgroup", "(", "h5group", ",", "spatial_img", ")", ":", "try", ":", "h5group", "[", "'data'", "]", "=", "spatial_img", ".", "get_data", "(", ")", "h5group", "[", "'affine'", "]", "=", "spatial_img", ".", "get_affine", "(", ")", "if",...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
spatialimg_to_hdfpath
Saves a Nifti1Image into an HDF5 file. Parameters ---------- file_path: string Output HDF5 file path spatial_img: nibabel SpatialImage Image to be saved h5path: string HDF5 group path where the image data will be saved. Datasets will be created inside the given gro...
boyle/nifti/storage.py
def spatialimg_to_hdfpath(file_path, spatial_img, h5path=None, append=True): """Saves a Nifti1Image into an HDF5 file. Parameters ---------- file_path: string Output HDF5 file path spatial_img: nibabel SpatialImage Image to be saved h5path: string HDF5 group path where...
def spatialimg_to_hdfpath(file_path, spatial_img, h5path=None, append=True): """Saves a Nifti1Image into an HDF5 file. Parameters ---------- file_path: string Output HDF5 file path spatial_img: nibabel SpatialImage Image to be saved h5path: string HDF5 group path where...
[ "Saves", "a", "Nifti1Image", "into", "an", "HDF5", "file", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L111-L157
[ "def", "spatialimg_to_hdfpath", "(", "file_path", ",", "spatial_img", ",", "h5path", "=", "None", ",", "append", "=", "True", ")", ":", "if", "h5path", "is", "None", ":", "h5path", "=", "'/img'", "mode", "=", "'w'", "if", "os", ".", "path", ".", "exist...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
hdfpath_to_nifti1image
Returns a nibabel Nifti1Image from a HDF5 group datasets Parameters ---------- file_path: string HDF5 file path h5path: HDF5 group path in file_path Returns ------- nibabel Nifti1Image
boyle/nifti/storage.py
def hdfpath_to_nifti1image(file_path, h5path): """Returns a nibabel Nifti1Image from a HDF5 group datasets Parameters ---------- file_path: string HDF5 file path h5path: HDF5 group path in file_path Returns ------- nibabel Nifti1Image """ with h5py.File(fil...
def hdfpath_to_nifti1image(file_path, h5path): """Returns a nibabel Nifti1Image from a HDF5 group datasets Parameters ---------- file_path: string HDF5 file path h5path: HDF5 group path in file_path Returns ------- nibabel Nifti1Image """ with h5py.File(fil...
[ "Returns", "a", "nibabel", "Nifti1Image", "from", "a", "HDF5", "group", "datasets" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L160-L176
[ "def", "hdfpath_to_nifti1image", "(", "file_path", ",", "h5path", ")", ":", "with", "h5py", ".", "File", "(", "file_path", ",", "'r'", ")", "as", "f", ":", "return", "hdfgroup_to_nifti1image", "(", "f", "[", "h5path", "]", ")" ]
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
hdfgroup_to_nifti1image
Returns a nibabel Nifti1Image from a HDF5 group datasets Parameters ---------- h5group: h5py.Group HDF5 group Returns ------- nibabel Nifti1Image
boyle/nifti/storage.py
def hdfgroup_to_nifti1image(h5group): """Returns a nibabel Nifti1Image from a HDF5 group datasets Parameters ---------- h5group: h5py.Group HDF5 group Returns ------- nibabel Nifti1Image """ try: data = h5group['data'][:] affine = h5group['affine'][:] ...
def hdfgroup_to_nifti1image(h5group): """Returns a nibabel Nifti1Image from a HDF5 group datasets Parameters ---------- h5group: h5py.Group HDF5 group Returns ------- nibabel Nifti1Image """ try: data = h5group['data'][:] affine = h5group['affine'][:] ...
[ "Returns", "a", "nibabel", "Nifti1Image", "from", "a", "HDF5", "group", "datasets" ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L179-L206
[ "def", "hdfgroup_to_nifti1image", "(", "h5group", ")", ":", "try", ":", "data", "=", "h5group", "[", "'data'", "]", "[", ":", "]", "affine", "=", "h5group", "[", "'affine'", "]", "[", ":", "]", "extra", "=", "None", "if", "'extra'", "in", "h5group", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
get_nifti1hdr_from_h5attrs
Transforms an H5py Attributes set to a dict. Converts unicode string keys into standard strings and each value into a numpy array. Parameters ---------- h5attrs: H5py Attributes Returns -------- dict
boyle/nifti/storage.py
def get_nifti1hdr_from_h5attrs(h5attrs): """Transforms an H5py Attributes set to a dict. Converts unicode string keys into standard strings and each value into a numpy array. Parameters ---------- h5attrs: H5py Attributes Returns -------- dict """ hdr = nib.Nifti1Header() ...
def get_nifti1hdr_from_h5attrs(h5attrs): """Transforms an H5py Attributes set to a dict. Converts unicode string keys into standard strings and each value into a numpy array. Parameters ---------- h5attrs: H5py Attributes Returns -------- dict """ hdr = nib.Nifti1Header() ...
[ "Transforms", "an", "H5py", "Attributes", "set", "to", "a", "dict", ".", "Converts", "unicode", "string", "keys", "into", "standard", "strings", "and", "each", "value", "into", "a", "numpy", "array", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L209-L226
[ "def", "get_nifti1hdr_from_h5attrs", "(", "h5attrs", ")", ":", "hdr", "=", "nib", ".", "Nifti1Header", "(", ")", "for", "k", "in", "list", "(", "h5attrs", ".", "keys", "(", ")", ")", ":", "hdr", "[", "str", "(", "k", ")", "]", "=", "np", ".", "ar...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
all_childnodes_to_nifti1img
Returns in a list all images found under h5group. Parameters ---------- h5group: h5py.Group HDF group Returns ------- list of nifti1Image
boyle/nifti/storage.py
def all_childnodes_to_nifti1img(h5group): """Returns in a list all images found under h5group. Parameters ---------- h5group: h5py.Group HDF group Returns ------- list of nifti1Image """ child_nodes = [] def append_parent_if_dataset(name, obj): if isinstance(obj...
def all_childnodes_to_nifti1img(h5group): """Returns in a list all images found under h5group. Parameters ---------- h5group: h5py.Group HDF group Returns ------- list of nifti1Image """ child_nodes = [] def append_parent_if_dataset(name, obj): if isinstance(obj...
[ "Returns", "in", "a", "list", "all", "images", "found", "under", "h5group", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L229-L252
[ "def", "all_childnodes_to_nifti1img", "(", "h5group", ")", ":", "child_nodes", "=", "[", "]", "def", "append_parent_if_dataset", "(", "name", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "h5py", ".", "Dataset", ")", ":", "if", "name", ".", ...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
insert_volumes_in_one_dataset
Inserts all given nifti files from file_list into one dataset in fname. This will not check if the dimensionality of all files match. Parameters ---------- file_path: string HDF5 file path h5path: string file_list: list of strings newshape: tuple or lambda function If Non...
boyle/nifti/storage.py
def insert_volumes_in_one_dataset(file_path, h5path, file_list, newshape=None, concat_axis=0, dtype=None, append=True): """Inserts all given nifti files from file_list into one dataset in fname. This will not check if the dimensionality of all files match. Parameters -...
def insert_volumes_in_one_dataset(file_path, h5path, file_list, newshape=None, concat_axis=0, dtype=None, append=True): """Inserts all given nifti files from file_list into one dataset in fname. This will not check if the dimensionality of all files match. Parameters -...
[ "Inserts", "all", "given", "nifti", "files", "from", "file_list", "into", "one", "dataset", "in", "fname", ".", "This", "will", "not", "check", "if", "the", "dimensionality", "of", "all", "files", "match", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/storage.py#L255-L382
[ "def", "insert_volumes_in_one_dataset", "(", "file_path", ",", "h5path", ",", "file_list", ",", "newshape", "=", "None", ",", "concat_axis", "=", "0", ",", "dtype", "=", "None", ",", "append", "=", "True", ")", ":", "def", "isalambda", "(", "v", ")", ":"...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
treefall
Generate all combinations of the elements of iterable and its subsets. Parameters ---------- iterable: list, set or dict or any iterable object Returns ------- A generator of all possible combinations of the iterable. Example: ------- >>> for i in treefall([1, 2, 3, 4, 5]): print(...
boyle/dicom/itertools.py
def treefall(iterable): """ Generate all combinations of the elements of iterable and its subsets. Parameters ---------- iterable: list, set or dict or any iterable object Returns ------- A generator of all possible combinations of the iterable. Example: ------- >>> for i ...
def treefall(iterable): """ Generate all combinations of the elements of iterable and its subsets. Parameters ---------- iterable: list, set or dict or any iterable object Returns ------- A generator of all possible combinations of the iterable. Example: ------- >>> for i ...
[ "Generate", "all", "combinations", "of", "the", "elements", "of", "iterable", "and", "its", "subsets", "." ]
Neurita/boyle
python
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/itertools.py#L5-L32
[ "def", "treefall", "(", "iterable", ")", ":", "num_elems", "=", "len", "(", "iterable", ")", "for", "i", "in", "range", "(", "num_elems", ",", "-", "1", ",", "-", "1", ")", ":", "for", "c", "in", "combinations", "(", "iterable", ",", "i", ")", ":...
2dae7199849395a209c887d5f30506e1de8a9ad9
valid
get_reliabledictionary_list
List existing reliable dictionaries. List existing reliable dictionaries and respective schema for given application and service. :param application_name: Name of the application. :type application_name: str :param service_name: Name of the service. :type service_name: str
rcctl/rcctl/custom_reliablecollections.py
def get_reliabledictionary_list(client, application_name, service_name): """List existing reliable dictionaries. List existing reliable dictionaries and respective schema for given application and service. :param application_name: Name of the application. :type application_name: str :param service...
def get_reliabledictionary_list(client, application_name, service_name): """List existing reliable dictionaries. List existing reliable dictionaries and respective schema for given application and service. :param application_name: Name of the application. :type application_name: str :param service...
[ "List", "existing", "reliable", "dictionaries", "." ]
shalabhms/reliable-collections-cli
python
https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/custom_reliablecollections.py#L12-L25
[ "def", "get_reliabledictionary_list", "(", "client", ",", "application_name", ",", "service_name", ")", ":", "cluster", "=", "Cluster", ".", "from_sfclient", "(", "client", ")", "service", "=", "cluster", ".", "get_application", "(", "application_name", ")", ".", ...
195d69816fb5a6e1e9ab0ab66b606b1248b4780d
valid
get_reliabledictionary_schema
Query Schema information for existing reliable dictionaries. Query Schema information existing reliable dictionaries for given application and service. :param application_name: Name of the application. :type application_name: str :param service_name: Name of the service. :type service_name: str ...
rcctl/rcctl/custom_reliablecollections.py
def get_reliabledictionary_schema(client, application_name, service_name, dictionary_name, output_file=None): """Query Schema information for existing reliable dictionaries. Query Schema information existing reliable dictionaries for given application and service. :param application_name: Name of the appl...
def get_reliabledictionary_schema(client, application_name, service_name, dictionary_name, output_file=None): """Query Schema information for existing reliable dictionaries. Query Schema information existing reliable dictionaries for given application and service. :param application_name: Name of the appl...
[ "Query", "Schema", "information", "for", "existing", "reliable", "dictionaries", "." ]
shalabhms/reliable-collections-cli
python
https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/custom_reliablecollections.py#L27-L51
[ "def", "get_reliabledictionary_schema", "(", "client", ",", "application_name", ",", "service_name", ",", "dictionary_name", ",", "output_file", "=", "None", ")", ":", "cluster", "=", "Cluster", ".", "from_sfclient", "(", "client", ")", "dictionary", "=", "cluster...
195d69816fb5a6e1e9ab0ab66b606b1248b4780d
valid
query_reliabledictionary
Query existing reliable dictionary. Query existing reliable dictionaries for given application and service. :param application_name: Name of the application. :type application_name: str :param service_name: Name of the service. :type service_name: str :param dictionary_name: Name of the reliab...
rcctl/rcctl/custom_reliablecollections.py
def query_reliabledictionary(client, application_name, service_name, dictionary_name, query_string, partition_key=None, partition_id=None, output_file=None): """Query existing reliable dictionary. Query existing reliable dictionaries for given application and service. :param application_name: Name of the ...
def query_reliabledictionary(client, application_name, service_name, dictionary_name, query_string, partition_key=None, partition_id=None, output_file=None): """Query existing reliable dictionary. Query existing reliable dictionaries for given application and service. :param application_name: Name of the ...
[ "Query", "existing", "reliable", "dictionary", "." ]
shalabhms/reliable-collections-cli
python
https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/custom_reliablecollections.py#L78-L124
[ "def", "query_reliabledictionary", "(", "client", ",", "application_name", ",", "service_name", ",", "dictionary_name", ",", "query_string", ",", "partition_key", "=", "None", ",", "partition_id", "=", "None", ",", "output_file", "=", "None", ")", ":", "cluster", ...
195d69816fb5a6e1e9ab0ab66b606b1248b4780d