Comments (3)
This is because the images are internally represented as pointers. Once
you close R and restart it, there's no way to recover where the pointer
points to. You will need to actually save the image as a Nifti (or
similar) and re-read from R.
On Fri, Dec 5, 2014 at 3:54 PM, dorianps [email protected] wrote:
I am having this issue all the time. AntsImages are unusuable if saved in
.R files and then reloaded.For example, I load antsImages in workspace, save the workspace, and
reload it again later. What happens is that antsImages seem to be there,
but are compromised. If I try to use them R goes in segmentaiton fault.
There are two examples below, first I load an .R file, use mask from
within it and R crashes. Second I remove mask and reload it again, and all
works.
Is this a bug or antsImages S4 objects simply cannot be saved?######################################
Welcome! Loading ANTsR...
ANTsR is loaded.load(file="subjectdata.R")
mask
An object of class "antsImage"
Slot "pixeltype":
[1] "float"Slot "dimension":
[1] 3Slot "pointer":
ls()
[1] "imageList" "mask" "mydata" "thick" "workfolder"
mat<-imagesToMatrix(imageList, mask)*** caught segfault ***
address (nil), cause 'memory not mapped'Traceback:
1: .Call("antsImage_RelationalOperators", e1, e2, region, operator,
PACKAGE = "ANTsR")
2: mask > 0
3: mask > 0
4: which(mask > 0)
5: imagesToMatrix(imageList, mask)Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: q()
Selection: 3
#########################################
working exampleWelcome! Loading ANTsR...
ANTsR is loaded.load(file="subjectdata.R")
rm(mask)
mask<-antsImageRead('processing/smo_4_NormCortThick/mask.nii.gz', 3)
mat<-imagesToMatrix(imageList, mask)—
Reply to this email directly or view it on GitHub
#7.
from antsr.
yes - ben is correct ... there is a way around this. if you convert the
image to an array, you can save ... but would have to reconvert back to an
image to use it as an image. there is probably a way to automate this
process and prevent this issue from happening: basically (optionally)
store the array within the ants image class. if the pointer is null then
reload the image from the array. maybe there is a better way, though.
brian
On Fri, Dec 5, 2014 at 3:59 PM, bkandel [email protected] wrote:
This is because the images are internally represented as pointers. Once
you close R and restart it, there's no way to recover where the pointer
points to. You will need to actually save the image as a Nifti (or
similar) and re-read from R.On Fri, Dec 5, 2014 at 3:54 PM, dorianps [email protected]
wrote:I am having this issue all the time. AntsImages are unusuable if saved
in
.R files and then reloaded.For example, I load antsImages in workspace, save the workspace, and
reload it again later. What happens is that antsImages seem to be there,
but are compromised. If I try to use them R goes in segmentaiton fault.
There are two examples below, first I load an .R file, use mask from
within it and R crashes. Second I remove mask and reload it again, and
all
works.
Is this a bug or antsImages S4 objects simply cannot be saved?######################################
Welcome! Loading ANTsR...
ANTsR is loaded.load(file="subjectdata.R")
mask
An object of class "antsImage"
Slot "pixeltype":
[1] "float"Slot "dimension":
[1] 3Slot "pointer":
ls()
[1] "imageList" "mask" "mydata" "thick" "workfolder"
mat<-imagesToMatrix(imageList, mask)*** caught segfault ***
address (nil), cause 'memory not mapped'Traceback:
1: .Call("antsImage_RelationalOperators", e1, e2, region, operator,
PACKAGE = "ANTsR")
2: mask > 0
3: mask > 0
4: which(mask > 0)
5: imagesToMatrix(imageList, mask)Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: q()
Selection: 3
#########################################
working exampleWelcome! Loading ANTsR...
ANTsR is loaded.load(file="subjectdata.R")
rm(mask)
mask<-antsImageRead('processing/smo_4_NormCortThick/mask.nii.gz', 3)
mat<-imagesToMatrix(imageList, mask)—
Reply to this email directly or view it on GitHub
#7.—
Reply to this email directly or view it on GitHub
#7 (comment).
from antsr.
Thank you. I had the feeling this was the case.
This might confuse users. It would be great if there is a way to skip the saving of antsImages, or convert automatically to array, or perhaps show a notice that antsImages cannot be saved/loaded from data files. By the way, from what I understand these are regular S4 objects, it's weird that R itself is allowing to save pointers like any other data class.
Dorian
from antsr.
Related Issues (20)
- Masking 4D image with 3D mask
- Install repeatedly wants to update ITKR
- How to iterate an iMath function over many images HOT 1
- fitTransformToPairedPoints diffeo example doesn't work HOT 2
- Installation fails on Ubuntu 22.04LTS with R4.2.0 HOT 3
- ERROR: Parsing error: The keyword 'const' is reserved
- Errors in buliding ANTsR vigniettes HOT 1
- AAL template extends beyond MNI cortical surface HOT 7
- installation problem antsLibs() Makevars:6: *** missing separator. Stop. HOT 5
- Error
- antsMotionCalculation Error HOT 1
- colorbar key for antsrSurf HOT 6
- Installation fail with devtools HOT 5
- details about mnib HOT 1
- Failing on ITK when running LINDA HOT 6
- Proper similarity metric for Affine registration HOT 3
- MVPA using ANTsR?
- ITK bug in createJacobianDeterminantImage after upgrade HOT 14
- aslPerfusion HOT 11
- Installation error on Mac OS 12.6.3 with devtools HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antsr.