This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Algorithm for concatenating half precision tensors by allocating new output matrix | |
of appropriate size and copying each of the constituent tensors into it with | |
appropriate offsets. | |
""" | |
import numpy as np | |
import torch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Pairwise distance module for pytorch. | |
""" | |
import torch.autograd as autograd | |
import torch.nn as nn | |
class PairwiseDistance(nn.Module): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Numerically stable algorithm for computing running sample variance. | |
Reference | |
--------- | |
.. [1] B.P. Welford. "Note on a method for calculating corrected sums of squares | |
and products", Technometrics, Vol. 4, No. 3, pp. 419-420. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Non-legacy View module for pytorch (http://pytorch.org) | |
""" | |
import torch.autograd as autograd | |
import torch.nn as nn | |
class View(nn.Module): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% How to only retain a fixed number of sublists that contain specific values. | |
% Sublists to analyze: | |
ids = {{0, 0}, {1, 0}, {0, 1, 2}, {0, 2}, {1, 2}, {0, 2}, {1, 1}}; | |
counts = [0, 0, 0]; | |
for i=1:length(ids), | |
id = cell2mat(ids{i}); | |
% Retain `id` only if it contains at least one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- How to copy a Torch model to a new type without explicit cloning. | |
-- Based on code in checkpoints.lua in http://github.com/facebook/fb.resnet.torch | |
require 'torch' | |
function copy_convert(obj, t) | |
local copy = {} | |
for k, v in pairs(obj) do | |
if type(v) == 'table' then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Filter out certain outputs in a nipype MapNode. | |
""" | |
import logging | |
import nipype | |
import nipype.interfaces.utility as utility |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Ensure Reorient2Std output is compressed or uncompressed as per output_type trait. | |
Notes | |
----- | |
Works around possible fslreorient2std bug: https://github.com/nipy/nipype/issues/1683 | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
How to normalize intensity of brain images to the range [0, 1] with nipype and FSL. | |
""" | |
import os.path | |
import nipype | |
import nipype.interfaces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Simple demo of a nipype pipeline that uses DataGrabber and DataSink. | |
""" | |
import os.path | |
import nipype | |
import nipype.interfaces.fsl as fsl |