From stjeansam at gmail.com Tue Aug 1 07:33:31 2017 From: stjeansam at gmail.com (Samuel St-Jean) Date: Tue, 1 Aug 2017 13:33:31 +0200 Subject: [Neuroimaging] noise estimation in non diffusion datasets In-Reply-To: References: <370a450e-b55c-faad-6156-df6231452cab@gmail.com> Message-ID: I unfortunately don't think it would work here, since you need to have a good idea of what to linear model stuff against (such as huge signal drop in dwi due to vibration or the fmri hrf function) it seems. It's also that linear modeling will shove in the error term anything not fitting correctly your model, which will include a tons more source of error than say (thermal) noise arising from error in your raw magnitude measurements. Simple linear models (without the generalised part) like I planned to use also assume normally distributed residuals, so it would likely overestimate stuff with magnitude data. It's also that I actually want to use a linear model to predict my data, and I was planning to use the noise estimation part as part of a regulariser while finding the coefficients for the equations, so it would lead to a kind of circular problem in my case here. Well anyway, if you have (or, well, anyone also reading this) a suggestion of model approach to use on non fmri data (I have no idea if it even exist, as plain structural something-weighted mri data might not follow any special experimental model), it could also give me ideas, I was just going for a plain good old matrix of random image patches as usual so far. 2017-07-31 13:39 GMT+02:00 Ariel Rokem : > Hi Samuel, > > On Sat, Jul 29, 2017 at 10:10 PM, Samuel St-Jean > wrote: > >> Hello, >> >> I've been trying out some stuff recently with another guy on 'legacy' >> datasets, which comprise CT scans and stuff like T1w which are 0.8x0.8x8 >> mm. Unsurprisingly, they also have huge gradient intensity since these >> things dates back from when I started high school. Anyway, they also have >> diffusion data and noise estimation stuff works kind of ok, but the other >> weighting and modality are mostly a no go or perhaps could be done way >> better) using the diffusion tools we have now. >> >> So far I've also tried an aonlm-like noise estimator, but I was wondering >> if people working with all types of datasets (I am mostly a diffusion mri >> person in the first place) had suggestions about good or commonly used >> noise estimator and where to find them? Most likely candidate for that >> would be the fmri guys I'd guess, and of course those scans did not have >> a/some noise maps back in the days. >> >> > You may be interested in this model-based approach: > > http://journal.frontiersin.org/article/10.3389/fnins.2013.00247/full > > It's somewhat related to this DWI method: https://pdfs.semanticscholar. > org/8e89/03f8092c27d159879a3a2429a771d21b7be8.pdf > > Cheers, > > Ariel > > >> Thanks for the help and pointers, >> >> Samuel >> >> >> _______________________________________________ >> Neuroimaging mailing list >> Neuroimaging at python.org >> https://mail.python.org/mailman/listinfo/neuroimaging >> > > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mauro.zucchelli88 at gmail.com Wed Aug 2 10:06:44 2017 From: mauro.zucchelli88 at gmail.com (Mauro Zucchelli) Date: Wed, 2 Aug 2017 16:06:44 +0200 Subject: [Neuroimaging] Second International Winter School on Brain Connectomics - October 9-13, 2017 Message-ID: Dear all, I?m writing you to inform about an event that will take place in October in Verona (Italy) and that may be of interest to you or someone in your group. After the 1st successful edition of last year, we are pleased to announce that we will be running the second edition of the School on Brain Connectomics from 9th to 13th October. Connectomics is one of the hottest inter-disciplinary topics today: it links computer science and engineering with life sciences and medicine. Connection networks grow over functional (fMRI, ASL, EEG, MEG) and structural (diffusion weighted MRI) data and the integration of the two in both static and dynamic conditions would shed light on the way our brain actually works. The goal of the School on Brain Connectomics is to gather the knowledge in the different fields that are touched by these topics providing the students a comprehensive view of this research area as well as awareness about the cutting-edge methodological, experimental and clinical aspects that are involved. Connectomics bridges signal and image processing with applied mathematics, graph theory and machine learning. This year we are happy to host 14 international speakers that are leading scientists in the respective fields. School official website: - http://brainconnectomics.org Dates: - 9-13 October, 2017 Location: - Department of Computer Science, University of Verona, Italy Organizing committee: - Gloria Menegaz (gloria.menegaz at univr.it) - Alessandro Daducci (alessandro.daducci at univr.it) - Silvia F. Storti (silviafrancesca.storti at univr.it) We are now accepting applications. If you are interested in participating to the school, or you need more information, please do not hesitate to contact us. Feel free to forward this invitation to anyone who might be interested! Best Regards On behalf of the organizing committee Mauro Zucchelli -------------- next part -------------- An HTML attachment was scrubbed... URL: From seanlitow at gmail.com Wed Aug 2 12:51:42 2017 From: seanlitow at gmail.com (Test Test) Date: Wed, 02 Aug 2017 12:51:42 -0400 Subject: [Neuroimaging] Neuroimaging Digest, Vol 27, Issue 2 In-Reply-To: References: Message-ID: <2fcb1e6c-092d-4bf1-afac-3ff08a6c1428@gmail.com> Test Test liked your message with Boxer for Android. On Aug 2, 2017 12:03 PM, neuroimaging-request at python.org wrote: Send Neuroimaging mailing list submissions to neuroimaging at python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/neuroimaging or, via email, send a message with subject or body 'help' to neuroimaging-request at python.org You can reach the person managing the list at neuroimaging-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Neuroimaging digest..." Today's Topics: 1. Second International Winter School on Brain Connectomics - October 9-13, 2017 (Mauro Zucchelli) ---------------------------------------------------------------------- Message: 1 Date: Wed, 2 Aug 2017 16:06:44 +0200 From: Mauro Zucchelli To: neuroimaging at python.org Subject: [Neuroimaging] Second International Winter School on Brain Connectomics - October 9-13, 2017 Message-ID: Content-Type: text/plain; charset="utf-8" Dear all, I?m writing you to inform about an event that will take place in October in Verona (Italy) and that may be of interest to you or someone in your group. After the 1st successful edition of last year, we are pleased to announce that we will be running the second edition of the School on Brain Connectomics from 9th to 13th October. Connectomics is one of the hottest inter-disciplinary topics today: it links computer science and engineering with life sciences and medicine. Connection networks grow over functional (fMRI, ASL, EEG, MEG) and structural (diffusion weighted MRI) data and the integration of the two in both static and dynamic conditions would shed light on the way our brain actually works. The goal of the School on Brain Connectomics is to gather the knowledge in the different fields that are touched by these topics providing the students a comprehensive view of this research area as well as awareness about the cutting-edge methodological, experimental and clinical aspects that are involved. Connectomics bridges signal and image processing with applied mathematics, graph theory and machine learning. This year we are happy to host 14 international speakers that are leading scientists in the respective fields. School official website: - http://brainconnectomics.org Dates: - 9-13 October, 2017 Location: - Department of Computer Science, University of Verona, Italy Organizing committee: - Gloria Menegaz (gloria.menegaz at univr.it) - Alessandro Daducci (alessandro.daducci at univr.it) - Silvia F. Storti (silviafrancesca.storti at univr.it) We are now accepting applications. If you are interested in participating to the school, or you need more information, please do not hesitate to contact us. Feel free to forward this invitation to anyone who might be interested! Best Regards On behalf of the organizing committee Mauro Zucchelli -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ Subject: Digest Footer _______________________________________________ Neuroimaging mailing list Neuroimaging at python.org https://mail.python.org/mailman/listinfo/neuroimaging ------------------------------ End of Neuroimaging Digest, Vol 27, Issue 2 ******************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From seanlitow at gmail.com Thu Aug 3 13:02:51 2017 From: seanlitow at gmail.com (Test Test) Date: Thu, 03 Aug 2017 13:02:51 -0400 Subject: [Neuroimaging] Neuroimaging Digest, Vol 27, Issue 3 In-Reply-To: References: Message-ID: Test Test liked your message with Boxer for Android. On Aug 3, 2017 12:08 PM, neuroimaging-request at python.org wrote: Send Neuroimaging mailing list submissions to neuroimaging at python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/neuroimaging or, via email, send a message with subject or body 'help' to neuroimaging-request at python.org You can reach the person managing the list at neuroimaging-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Neuroimaging digest..." Today's Topics: 1. Re: Neuroimaging Digest, Vol 27, Issue 2 (Test Test) ---------------------------------------------------------------------- Message: 1 Date: Wed, 02 Aug 2017 12:51:42 -0400 From: Test Test To: neuroimaging at python.org Subject: Re: [Neuroimaging] Neuroimaging Digest, Vol 27, Issue 2 Message-ID: <2fcb1e6c-092d-4bf1-afac-3ff08a6c1428 at gmail.com> Content-Type: text/plain; charset="utf-8" Test Test liked your message with Boxer for Android. On Aug 2, 2017 12:03 PM, neuroimaging-request at python.org wrote: Send Neuroimaging mailing list submissions to neuroimaging at python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/neuroimaging or, via email, send a message with subject or body 'help' to neuroimaging-request at python.org You can reach the person managing the list at neuroimaging-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Neuroimaging digest..." Today's Topics: 1. Second International Winter School on Brain Connectomics - October 9-13, 2017 (Mauro Zucchelli) ---------------------------------------------------------------------- Message: 1 Date: Wed, 2 Aug 2017 16:06:44 +0200 From: Mauro Zucchelli To: neuroimaging at python.org Subject: [Neuroimaging] Second International Winter School on Brain Connectomics - October 9-13, 2017 Message-ID: Content-Type: text/plain; charset="utf-8" Dear all, I?m writing you to inform about an event that will take place in October in Verona (Italy) and that may be of interest to you or someone in your group. After the 1st successful edition of last year, we are pleased to announce that we will be running the second edition of the School on Brain Connectomics from 9th to 13th October. Connectomics is one of the hottest inter-disciplinary topics today: it links computer science and engineering with life sciences and medicine. Connection networks grow over functional (fMRI, ASL, EEG, MEG) and structural (diffusion weighted MRI) data and the integration of the two in both static and dynamic conditions would shed light on the way our brain actually works. The goal of the School on Brain Connectomics is to gather the knowledge in the different fields that are touched by these topics providing the students a comprehensive view of this research area as well as awareness about the cutting-edge methodological, experimental and clinical aspects that are involved. Connectomics bridges signal and image processing with applied mathematics, graph theory and machine learning. This year we are happy to host 14 international speakers that are leading scientists in the respective fields. School official website: - http://brainconnectomics.org Dates: - 9-13 October, 2017 Location: - Department of Computer Science, University of Verona, Italy Organizing committee: - Gloria Menegaz (gloria.menegaz at univr.it) - Alessandro Daducci (alessandro.daducci at univr.it) - Silvia F. Storti (silviafrancesca.storti at univr.it) We are now accepting applications. If you are interested in participating to the school, or you need more information, please do not hesitate to contact us. Feel free to forward this invitation to anyone who might be interested! Best Regards On behalf of the organizing committee Mauro Zucchelli -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ Subject: Digest Footer _______________________________________________ Neuroimaging mailing list Neuroimaging at python.org https://mail.python.org/mailman/listinfo/neuroimaging ------------------------------ End of Neuroimaging Digest, Vol 27, Issue 2 ******************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ Subject: Digest Footer _______________________________________________ Neuroimaging mailing list Neuroimaging at python.org https://mail.python.org/mailman/listinfo/neuroimaging ------------------------------ End of Neuroimaging Digest, Vol 27, Issue 3 ******************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From satra at mit.edu Tue Aug 8 23:27:56 2017 From: satra at mit.edu (Satrajit Ghosh) Date: Tue, 8 Aug 2017 23:27:56 -0400 Subject: [Neuroimaging] Seeking an HPC Data scientist Message-ID: The Department of Brain and Cognitive Sciences seeks an expert in machine learning and high-performance computing to collaborate on cutting edge research on neuroscience, perception, cognition, and artificial intelligence. The department is a world leader in computational approaches to brain science, and is home to state-of- the-art computing resources. Salary will be competitive with industry. To apply: https://careers.peopleclick.com/careerscp/client_mit/externa l/jobDetails.do?functionName=getJobDetail&jobPostId=10436&localeCode=en-us For more information about our department: https://bcs.mit.edu/ Job Description: PROGRAMMER/SOFTWARE DEVELOPMENT ENGINEER/COMPUTATIONAL AND MACHINE LEARNING SPECIALIST, Brain and Cognitive Sciences, to help tackle challenging problems in high-performance computing methods and systems, machine learning, management of large datasets, and artificial intelligence. Responsibilities include helping researchers translate computational algorithms into efficiently functioning (especially parallelized and GPU optimized) code; assisting with installation and implementation of third-party tools; staying up-to- date with cutting-edge computational techniques; providing guidance for storage and management of large data sets; developing and maintaining online courses for computing resources, running in-person tutorials on specific software packages/tools, and helping transition users to new computing tools; providing educational support and training to users of the departmental computing cluster; and monitoring cluster usage and resolving problems. Job Requirements: Bachelor?s degree (advanced degree preferred) in a scientific field or computer science; at least four years? experience in scientific high-performance (cluster) computing; familiarity with Slurm and Lustre; broad computational background with knowledge of Unix, HPC algorithms, GPU computing, programming models, debuggers, and performance tools; software development experience, especially Python and MATLAB, but also R, Lua, JavaScript, etc.; knowledge of high-level APIs for HPC computing; expertise installing and maintaining third-party software in an HPC environment and with container technology, especially in the context of computational reproducibility; familiarity with mathematical algorithms for high- performance computing, use or design of HPC profiling or optimization tools, and deep neural networks; ability to work effectively with scientists and engineers; initiative, tact, and judgment in developing solutions for users; excellent interpersonal skills and ability to communicate effectively, orally, in writing, and via live presentations; demonstrated ability to assume leadership roles, grasp complex problems, and develop solutions; and extensive background in high- performance computing. MIT is an equal employment opportunity employer. All qualified applicants will receive consideration for employment and will not be discriminated against on the basis of race, color, sex, sexual orientation, gender identity, religion, disability, age, genetic information, veteran status, ancestry, or national or ethnic origin. -------------- next part -------------- An HTML attachment was scrubbed... URL: From romain.valabregue at upmc.fr Thu Aug 17 11:06:50 2017 From: romain.valabregue at upmc.fr (valabregue) Date: Thu, 17 Aug 2017 17:06:50 +0200 Subject: [Neuroimaging] nibabel apply affine and resample Message-ID: <7a5c9e0a-84db-00f0-e5cf-58fd5d792ed8@upmc.fr> Dear all 1) Sorry for the basic question (this may be just a python question ...) How do I change the affine associate to the image img = nibabel.load('file') img.affine = newaffine #this give the error can't set attribute # so I need to do img.affine[:] = newaffine[:] is it the correct way to change the affine ? For what I need this work (: apply coregistration and reslice) 2) Second question about the resample_from_to this take a non negligeable time to compute since it is for the all volume. If I only need 3 slices, is there a way to gain time by reslicing only the request silces ? Many thanks Romain From mike.jarrett at ubc.ca Fri Aug 18 01:18:29 2017 From: mike.jarrett at ubc.ca (Mike Jarrett) Date: Fri, 18 Aug 2017 05:18:29 +0000 Subject: [Neuroimaging] PAR/REC scaling in nibabel Message-ID: Hello experts! After some trial and error, I've discovered that (at least in the cases I've checked), the default action of nib.parrec.load('file.PAR') is to scale the rec image to "display values". In other words, > nib.parrec.load('file.PAR').get_data() returns the same values as > nib.parrec.load('file.PAR',scaling='dv').get_data() Is this the intended behaviour? The docs don't seem to explicitly say that scaling='dv' is the default, only that setting the scaling value is optional. I had naively expected that not setting a preferred scaling would return the raw unscaled values. Could anyone shed light on this for me? I now know I can just set scaling='fp' to get floating point values, but it would put my mind at ease if someone could confirm that I'm looking at this correctly. Thanks! Mike Jarrett -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwaskom at nyu.edu Fri Aug 18 11:00:01 2017 From: mwaskom at nyu.edu (Michael Waskom) Date: Fri, 18 Aug 2017 11:00:01 -0400 Subject: [Neuroimaging] [Nibabel] Crop image volume? Message-ID: Hi Matthew, Is there a nibabel function to crop a 3D image? I want to resample data to match my anatomical, but to save space I want to crop the anatomical on the xyz dimensions to a tight box around the brain volume. In other words I want to take: >>> img.shape --> (256, 256, 256) >>> cropped_img = nib.crop_image(img, [(50, 200), (50, 200), (50, 200)]) >>> cropped_img.shape --> (150, 150, 150) If there isn't a function to do this, could you share a recipe for what I'd need to do? My sense is I'd need to a) pass a cropped data array (easy) b) change the data shape information in the header (easy) c) change the fourth column of the affine matrix (tricky!) Thanks, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From effigies at bu.edu Fri Aug 18 11:39:38 2017 From: effigies at bu.edu (Christopher Markiewicz) Date: Fri, 18 Aug 2017 11:39:38 -0400 Subject: [Neuroimaging] [Nibabel] Crop image volume? In-Reply-To: References: Message-ID: Michael, It's easier than it first looks. Steps 1 and 2, assuming a skull-stripped image: mask = nb.load(brainmask) bounds = np.sort(np.vstack(np.nonzero(mask.get_data())))[:, [0, -1]] x, y, z = bounds new_data = mask.get_data()[x[0]:x[1], y[0]:y[1], z[0]:z[1]] Step 3: Given A, we want to find A' that is identical up to the intercept, such that A * [x_0, y_0, z_0, 1]' == A' * [0, 0, 0, 1]. Conveniently, A' * [0, 0, 0, 1]' is the fourth row in the affine matrix, so we're done as soon as we calculate the LHS: new_aff = mask.affine.copy() new_aff[:, [3]] = mask.affine.dot(np.vstack((bounds[:, [0]], [1]))) new_img = nb.Nifti1Image(new_data, new_aff, mask.header) Chris On Fri, Aug 18, 2017 at 11:00 AM, Michael Waskom wrote: > Hi Matthew, > > Is there a nibabel function to crop a 3D image? I want to resample data to > match my anatomical, but to save space I want to crop the anatomical on the > xyz dimensions to a tight box around the brain volume. > > In other words I want to take: > > >>> img.shape > --> (256, 256, 256) > >>> cropped_img = nib.crop_image(img, [(50, 200), (50, 200), (50, 200)]) > >>> cropped_img.shape > --> (150, 150, 150) > > If there isn't a function to do this, could you share a recipe for what > I'd need to do? My sense is I'd need to a) pass a cropped data array (easy) > b) change the data shape information in the header (easy) c) change the > fourth column of the affine matrix (tricky!) > > Thanks, > Michael > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwaskom at nyu.edu Fri Aug 18 13:49:24 2017 From: mwaskom at nyu.edu (Michael Waskom) Date: Fri, 18 Aug 2017 13:49:24 -0400 Subject: [Neuroimaging] [Nibabel] Crop image volume? In-Reply-To: References: Message-ID: Thanks Chris, this seems to work well. Could be a nice addition to nibabel.funcs too! On Fri, Aug 18, 2017 at 11:39 AM, Christopher Markiewicz wrote: > Michael, > > It's easier than it first looks. Steps 1 and 2, assuming a skull-stripped > image: > > mask = nb.load(brainmask) > bounds = np.sort(np.vstack(np.nonzero(mask.get_data())))[:, [0, -1]] > x, y, z = bounds > > new_data = mask.get_data()[x[0]:x[1], y[0]:y[1], z[0]:z[1]] > > Step 3: > > Given A, we want to find A' that is identical up to the intercept, such > that A * [x_0, y_0, z_0, 1]' == A' * [0, 0, 0, 1]. > Conveniently, A' * [0, 0, 0, 1]' is the fourth row in the affine matrix, > so we're done as soon as we calculate the LHS: > > new_aff = mask.affine.copy() > new_aff[:, [3]] = mask.affine.dot(np.vstack((bounds[:, [0]], [1]))) > > new_img = nb.Nifti1Image(new_data, new_aff, mask.header) > > Chris > > > On Fri, Aug 18, 2017 at 11:00 AM, Michael Waskom wrote: > >> Hi Matthew, >> >> Is there a nibabel function to crop a 3D image? I want to resample data >> to match my anatomical, but to save space I want to crop the anatomical on >> the xyz dimensions to a tight box around the brain volume. >> >> In other words I want to take: >> >> >>> img.shape >> --> (256, 256, 256) >> >>> cropped_img = nib.crop_image(img, [(50, 200), (50, 200), (50, 200)]) >> >>> cropped_img.shape >> --> (150, 150, 150) >> >> If there isn't a function to do this, could you share a recipe for what >> I'd need to do? My sense is I'd need to a) pass a cropped data array (easy) >> b) change the data shape information in the header (easy) c) change the >> fourth column of the affine matrix (tricky!) >> >> Thanks, >> Michael >> >> _______________________________________________ >> Neuroimaging mailing list >> Neuroimaging at python.org >> https://mail.python.org/mailman/listinfo/neuroimaging >> >> > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwaskom at nyu.edu Fri Aug 18 16:52:47 2017 From: mwaskom at nyu.edu (Michael Waskom) Date: Fri, 18 Aug 2017 16:52:47 -0400 Subject: [Neuroimaging] [Nibabel] up/downsample image in Python Message-ID: Hi Matthew/Chris/others, Building on my previous question, I would also like to implement a pure-python downsampling of my images. I have done: import nibabel as nib from scipy import ndimage img = nib.load("brain.nii") data = img.get_data() lowres_data = ndimage.zoom(data, .5) zoom_xfm = np.eye(4) zoom_xfm[:3, :3] /= .5 lowres_affine = img.affine.dot(zoom_xfm) lowres_img = nib.Nifti1Image(lowres_data, lowres_affine, img.header) lowres_img.to_fileame("lowres_brain.nii") This is very close, but when I view the resulting image in Freeview (my downsampled image is also slightly stretched relative to the anatomical). I can also compare to the result from mri_convert, i.e. mri_convert brain.nii -vs 2 2 2 lowres_brain.nii. The resulting image is not stretched relative to the hires brain, so it's not an artifact on Freeview's side. The images also don't have an identical affine (it is off by 0.5 in the third row of the final column. What am I missing about how to alter to affine of a downsampled image? Alternative, is ndimage.zoom not the right Python function to use here? Best, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From grlee77 at gmail.com Fri Aug 18 17:30:50 2017 From: grlee77 at gmail.com (Gregory Lee) Date: Fri, 18 Aug 2017 17:30:50 -0400 Subject: [Neuroimaging] PAR/REC scaling in nibabel In-Reply-To: References: Message-ID: Hi Mike, Yes, the default is 'dv'. The documentation could be updated to make this clearer. p.s. Depending on the data you have, one other thing to watch out for is the strict_sort flag. I recommend always setting strict_sort=True, but it is False by default for reasons of backwards compatibility. It won't matter for simple 3D structural scans or standard fMRI timeseries data, but for anything with additional dimensions (such as echoes, ASL tagging labels, etc) it prevents things from potentially getting mis-sorted. It doesn't hurt to always have it on by default. On Fri, Aug 18, 2017 at 1:18 AM, Mike Jarrett wrote: > Hello experts! > > After some trial and error, I've discovered that (at least in the cases > I've checked), the default action of nib.parrec.load('file.PAR') is to > scale the rec image to "display values". > > In other words, > > nib.parrec.load('file.PAR').get_data() > returns the same values as > > nib.parrec.load('file.PAR',scaling='dv').get_data() > > Is this the intended behaviour? The docs don't seem to explicitly say that > scaling='dv' is the default, only that setting the scaling value is > optional. I had naively expected that not setting a preferred scaling would > return the raw unscaled values. > > Could anyone shed light on this for me? I now know I can just set > scaling='fp' to get floating point values, but it would put my mind at ease > if someone could confirm that I'm looking at this correctly. > > Thanks! > > Mike Jarrett > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From effigies at bu.edu Fri Aug 18 17:28:32 2017 From: effigies at bu.edu (Christopher Markiewicz) Date: Fri, 18 Aug 2017 17:28:32 -0400 Subject: [Neuroimaging] [Nibabel] up/downsample image in Python In-Reply-To: References: Message-ID: Hi Michael, At first glance this looks reasonable to me, so if I were to try to figure out the issue, I'd probably end up digging through nilearn's image resampling, which uses ndimage.affine_transform under the hood [0]. It's a much more flexible function that what you're looking for, but I think you should be able to find what you need in all of that. I'm also pretty sure that, with a nipy image, you can do this with `img[::2, ::2, ::2]`, but not sure quite where to point you to in that codebase. Chris [0] https://github.com/nilearn/nilearn/blob/master/nilearn/image/resampling.py#L221-L271 On Fri, Aug 18, 2017 at 4:52 PM, Michael Waskom wrote: > Hi Matthew/Chris/others, > > Building on my previous question, I would also like to implement a > pure-python downsampling of my images. I have done: > > import nibabel as nib > from scipy import ndimage > img = nib.load("brain.nii") > data = img.get_data() > lowres_data = ndimage.zoom(data, .5) > zoom_xfm = np.eye(4) > zoom_xfm[:3, :3] /= .5 > lowres_affine = img.affine.dot(zoom_xfm) > lowres_img = nib.Nifti1Image(lowres_data, lowres_affine, img.header) > lowres_img.to_fileame("lowres_brain.nii") > > This is very close, but when I view the resulting image in Freeview (my > downsampled image is also slightly stretched relative to the anatomical). > > I can also compare to the result from mri_convert, i.e. mri_convert > brain.nii -vs 2 2 2 lowres_brain.nii. The resulting image is not > stretched relative to the hires brain, so it's not an artifact on > Freeview's side. The images also don't have an identical affine (it is off > by 0.5 in the third row of the final column. > > What am I missing about how to alter to affine of a downsampled image? > Alternative, is ndimage.zoom not the right Python function to use here? > > Best, > Michael > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From satra at mit.edu Fri Aug 18 17:42:56 2017 From: satra at mit.edu (Satrajit Ghosh) Date: Sat, 19 Aug 2017 05:42:56 +0800 Subject: [Neuroimaging] [Nibabel] up/downsample image in Python In-Reply-To: References: Message-ID: hi michael, for downsampling, you should really consider an anti-aliasing filter. i don't believe zoom uses one. https://en.wikipedia.org/wiki/Image_scaling cheers, satra On Sat, Aug 19, 2017 at 4:52 AM, Michael Waskom wrote: > Hi Matthew/Chris/others, > > Building on my previous question, I would also like to implement a > pure-python downsampling of my images. I have done: > > import nibabel as nib > from scipy import ndimage > img = nib.load("brain.nii") > data = img.get_data() > lowres_data = ndimage.zoom(data, .5) > zoom_xfm = np.eye(4) > zoom_xfm[:3, :3] /= .5 > lowres_affine = img.affine.dot(zoom_xfm) > lowres_img = nib.Nifti1Image(lowres_data, lowres_affine, img.header) > lowres_img.to_fileame("lowres_brain.nii") > > This is very close, but when I view the resulting image in Freeview (my > downsampled image is also slightly stretched relative to the anatomical). > > I can also compare to the result from mri_convert, i.e. mri_convert > brain.nii -vs 2 2 2 lowres_brain.nii. The resulting image is not > stretched relative to the hires brain, so it's not an artifact on > Freeview's side. The images also don't have an identical affine (it is off > by 0.5 in the third row of the final column. > > What am I missing about how to alter to affine of a downsampled image? > Alternative, is ndimage.zoom not the right Python function to use here? > > Best, > Michael > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike.jarrett at ubc.ca Fri Aug 18 18:39:26 2017 From: mike.jarrett at ubc.ca (Mike Jarrett) Date: Fri, 18 Aug 2017 22:39:26 +0000 Subject: [Neuroimaging] PAR/REC scaling in nibabel In-Reply-To: References: Message-ID: Thanks Gregory, that's really helpful. On Fri, Aug 18, 2017 at 2:30 PM Gregory Lee wrote: > Hi Mike, > > Yes, the default is 'dv'. The documentation could be updated to make this > clearer. > > p.s. > Depending on the data you have, one other thing to watch out for is the > strict_sort flag. I recommend always setting strict_sort=True, but it is > False by default for reasons of backwards compatibility. It won't matter > for simple 3D structural scans or standard fMRI timeseries data, but for > anything with additional dimensions (such as echoes, ASL tagging labels, > etc) it prevents things from potentially getting mis-sorted. It doesn't > hurt to always have it on by default. > > > > On Fri, Aug 18, 2017 at 1:18 AM, Mike Jarrett wrote: > >> Hello experts! >> >> After some trial and error, I've discovered that (at least in the cases >> I've checked), the default action of nib.parrec.load('file.PAR') is to >> scale the rec image to "display values". >> >> In other words, >> > nib.parrec.load('file.PAR').get_data() >> returns the same values as >> > nib.parrec.load('file.PAR',scaling='dv').get_data() >> >> Is this the intended behaviour? The docs don't seem to explicitly say >> that scaling='dv' is the default, only that setting the scaling value is >> optional. I had naively expected that not setting a preferred scaling would >> return the raw unscaled values. >> >> Could anyone shed light on this for me? I now know I can just set >> scaling='fp' to get floating point values, but it would put my mind at ease >> if someone could confirm that I'm looking at this correctly. >> >> Thanks! >> >> Mike Jarrett >> >> _______________________________________________ >> Neuroimaging mailing list >> Neuroimaging at python.org >> https://mail.python.org/mailman/listinfo/neuroimaging >> >> > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bertrand.thirion at inria.fr Sat Aug 19 05:01:25 2017 From: bertrand.thirion at inria.fr (bthirion) Date: Sat, 19 Aug 2017 11:01:25 +0200 Subject: [Neuroimaging] [Nibabel] up/downsample image in Python In-Reply-To: References: Message-ID: <13265922-bd55-cab4-ae7b-1184c5171d72@inria.fr> I would indeed try nilearn.image.resample_img() B On 18/08/2017 23:28, Christopher Markiewicz wrote: > Hi Michael, > > At first glance this looks reasonable to me, so if I were to try to > figure out the issue, I'd probably end up digging through nilearn's > image resampling, which uses ndimage.affine_transform under the hood > [0]. It's a much more flexible function that what you're looking for, > but I think you should be able to find what you need in all of that. > > I'm also pretty sure that, with a nipy image, you can do this with > `img[::2, ::2, ::2]`, but not sure quite where to point you to in that > codebase. > > Chris > > [0] > https://github.com/nilearn/nilearn/blob/master/nilearn/image/resampling.py#L221-L271 > > On Fri, Aug 18, 2017 at 4:52 PM, Michael Waskom > wrote: > > Hi Matthew/Chris/others, > > Building on my previous question, I would also like to implement a > pure-python downsampling of my images. I have done: > > import nibabel as nib > from scipy import ndimage > img = nib.load("brain.nii") > data = img.get_data() > lowres_data = ndimage.zoom(data, .5) > zoom_xfm = np.eye(4) > zoom_xfm[:3, :3] /= .5 > lowres_affine = img.affine.dot(zoom_xfm) > lowres_img = nib.Nifti1Image(lowres_data, lowres_affine, img.header) > lowres_img.to_fileame("lowres_brain.nii") > > This is very close, but when I view the resulting image in > Freeview (my downsampled image is also slightly stretched relative > to the anatomical). > > I can also compare to the result from mri_convert, i.e. > mri_convert brain.nii -vs 2 2 2 lowres_brain.nii. The resulting > image is not stretched relative to the hires brain, so it's not an > artifact on Freeview's side. The images also don't have an > identical affine (it is off by 0.5 in the third row of the final > column. > > What am I missing about how to alter to affine of a downsampled > image? Alternative, is ndimage.zoom not the right Python function > to use here? > > Best, > Michael > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > > > > > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew.brett at gmail.com Sat Aug 19 06:21:25 2017 From: matthew.brett at gmail.com (Matthew Brett) Date: Sat, 19 Aug 2017 11:21:25 +0100 Subject: [Neuroimaging] [Nibabel] up/downsample image in Python In-Reply-To: References: Message-ID: Hi Michael, On Fri, Aug 18, 2017 at 9:52 PM, Michael Waskom wrote: > Hi Matthew/Chris/others, > > Building on my previous question, I would also like to implement a > pure-python downsampling of my images. I have done: > > import nibabel as nib > from scipy import ndimage > img = nib.load("brain.nii") > data = img.get_data() > lowres_data = ndimage.zoom(data, .5) > zoom_xfm = np.eye(4) > zoom_xfm[:3, :3] /= .5 > lowres_affine = img.affine.dot(zoom_xfm) > lowres_img = nib.Nifti1Image(lowres_data, lowres_affine, img.header) > lowres_img.to_fileame("lowres_brain.nii") > > This is very close, but when I view the resulting image in Freeview (my > downsampled image is also slightly stretched relative to the anatomical). > > I can also compare to the result from mri_convert, i.e. mri_convert > brain.nii -vs 2 2 2 lowres_brain.nii. The resulting image is not stretched > relative to the hires brain, so it's not an artifact on Freeview's side. The > images also don't have an identical affine (it is off by 0.5 in the third > row of the final column. > > What am I missing about how to alter to affine of a downsampled image? > Alternative, is ndimage.zoom not the right Python function to use here? Did you find nibabel.processing.resample_from_to ? Not surprising if you didn't - it's not well documented yet. The nipy method is very nice, we really should port it across to nibabel. It just adapts the affine to the numpy slicing you've done: https://github.com/practical-neuroimaging/analysis-clinic/blob/master/nipy_image_slicing.ipynb Cheers, Matthew From romain.valabregue at upmc.fr Mon Aug 21 05:09:20 2017 From: romain.valabregue at upmc.fr (valabregue) Date: Mon, 21 Aug 2017 11:09:20 +0200 Subject: [Neuroimaging] [Nibabel] up/downsample image in Python In-Reply-To: References: Message-ID: Hello I also notice that if you just apply a zoom you end up with an affine with the exact same translation. If I now compare with the reslice done by mrtrix ( mrresize img1.nii -vox 2 img2.nii) I get almost the same except it changes translation of the affine by 1mm. I tried to understand what exact shift one need to add but I can find the solution. (affter testing different resampling 2 3 4 mn, I do not get what is exactly done) It may have something to do with the 'world space coordinate' which refer to the center of the voxel (not sure what the convention is). if this is the center it makes sens that on need to apply a shift to keep the data align. however I can not figure the correct shift to apply Here is the code I use to apply zoom and translation img=ni.load('img1.nii') translations, rotations, zooms, shears =transforms3d.affines.decompose44(img.affine) newzooms=zooms*2 shift = (newzooms-zooms)/2 #shift = (newzooms)/2 #neither of the previous 2 shifts gives the one use by mrtirx newtranslations=translations+shift newaff=transforms3d.affines.compose(newtranslations,rotations,newzooms,shears) ii=nip.resample_from_to(img,(np.array(img.shape)/2,newaff)) ii.to_filename('lowres.nii') cheers Romain On 08/18/2017 10:52 PM, Michael Waskom wrote: > Hi Matthew/Chris/others, > > Building on my previous question, I would also like to implement a > pure-python downsampling of my images. I have done: > > import nibabel as nib > from scipy import ndimage > img = nib.load("brain.nii") > data = img.get_data() > lowres_data = ndimage.zoom(data, .5) > zoom_xfm = np.eye(4) > zoom_xfm[:3, :3] /= .5 > lowres_affine = img.affine.dot(zoom_xfm) > lowres_img = nib.Nifti1Image(lowres_data, lowres_affine, img.header) > lowres_img.to_fileame("lowres_brain.nii") > > This is very close, but when I view the resulting image in Freeview > (my downsampled image is also slightly stretched relative to the > anatomical). > > I can also compare to the result from mri_convert, i.e. mri_convert > brain.nii -vs 2 2 2 lowres_brain.nii. The resulting image is not > stretched relative to the hires brain, so it's not an artifact on > Freeview's side. The images also don't have an identical affine (it is > off by 0.5 in the third row of the final column. > > What am I missing about how to alter to affine of a downsampled image? > Alternative, is ndimage.zoom not the right Python function to use here? > > Best, > Michael > > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging -------------- next part -------------- An HTML attachment was scrubbed... URL: From arokem at gmail.com Wed Aug 30 17:08:56 2017 From: arokem at gmail.com (Ariel Rokem) Date: Wed, 30 Aug 2017 14:08:56 -0700 Subject: [Neuroimaging] Software carpentry at the annual meeting of the Society for Neuroscience Message-ID: Software Carpentry is a non-profit volunteer organization whose members teach researchers computing skills. On November 9th-10th INCF will hold a two-day Software Carpentry workshop at the George Washington University Marvin Center in Washington DC, to dovetail with the annual meeting of the Society for Neuroscience. The workshop will focus on software tools to make researchers more effective, allowing them to automate research tasks, track their research over time, and use programming to accelerate their research, and make it more reproducible. For details about the workshop please refer to the following web-page: https://incf.github.io/2017-11-09-sfn/ Participation is *free*, but because space is limited, we ask that participants apply to participate through the following web form: https://goo.gl/forms/09QyOPp3hFzw4ln63 *Application deadline is September 11th* Feel free to distribute this message widely among your colleagues, and to email me (Ariel Rokem: arokem at uw.edu) with any questions about the workshop. -- Apologies for cross-posting -- -------------- next part -------------- An HTML attachment was scrubbed... URL: