Adding additional specimens to digitize in geomorph

477 views
Skip to first unread message

Christina Painting

unread,
Aug 10, 2017, 11:15:07 PM8/10/17
to geomorph R package
Good afternoon,

I've been learning to 2D digitize photographs of beetles in geomorph and have created a tps file. I wondered if it was possible to:

1) Digitize further specimens and add to the same tps file 

The reason for this is that I realised I had some photographs labelled as uppercase .JPG, unlike the rest of the folder which was lowercase .jpg, so the function registered that I'd finished digitizing all my specimens when I actually had another bunch to complete with the wrong file type. In general though it would be helpful if wanting to increase sample size at a later point in a project

I tried just adding more photographs to the same folder and re running the digitize2d function but I get an error message (Error in digitize2d(filelist = filelist, nlandmarks = 47, scale = 1, tpsfile = "anthribids.tps",  :   Filelist not the same length as input TPS file.)

I wonder if possible to digitize further specimens either in the same folder (and send to same tps file) or to combine 2 tps files later in geomorph

2) Remove any specimens from the tps file that may need to be re-digitized (i.e. to discard first 20 for burn-in or if you knew you made a mistake)


Many thanks for your help

Chrissie Painting

Research Fellow
School of Biological Sciences
University of Auckland
New Zealand 

Emma Sherratt

unread,
Aug 11, 2017, 12:33:32 AM8/11/17
to geomorph R package
Dear Chrissie,

You raise a very good question. So what is needed is that the new specimens are listed in the TPS for the digitize2d function to work properly. This is a functionality we can add to the next version, but for now, here is an easy fix:

filelist <- list.files() # use list.files to get a list of just the new pictures to digitise. 
newdata <- array(0, c(nlandmarks, 2, length(filelist))) # change nlanmdarks to 47 for your data
dimnames(newdata)[[3]] <- as.list(filelist)
writeland.tps(newdata, "newTPSfile.tps") # write an empty tps file to the directory

Then open the new and your original tps files, and copy and paste the whole of the new onto the end of the old file. Then when all the pictures (old and new) are in the same working directory, with your newly appended tps file, digitize2d should work correctly.

Em

Christina Painting

unread,
Aug 14, 2017, 6:54:05 PM8/14/17
to geomorph R package
Dear Emma,

Thanks so much for your very helpful reply! Your suggestion worked and I was able to digitize all the remaining specimens. 

A slightly strange thing happened though, where I noticed that in the new TPS file all the new photos had varying scales. I had set this to 1 and used the same scale bar as in all the other photos, but I noticed that each of the new specimens had a scale that varied and was always much smaller than 1 (e.g. SCALE=0.00550118402338082, SCALE=0.00332694421655946 and so on). When I plot out the PCA shape-wise everything looks fine, but the centroid sizes for those specimens with very small scale values are wildly different from the rest of the specimens with scale = 1 (i.e. much smaller centroid values than the other specimens).

Any ideas what I may have done wrong here? 

To clarify the steps I did, I ran the code as you wrote in prev reply. Then I cut and pasted only the specimens that were missing from the old file onto a newly named TPS file so that I would only be digitizing the new photos. So my new file had the landmark info for all the specimens I'd digitized already, and then a set of new specimens with all the landmarks at zeros. Worked fine when re-running digitize2d again, and only noticed the issue when inspecting the centroid sizes. 

digitize2d(filelist = filelist, nlandmarks = 47, scale = 1, tpsfile = "anthribids3.tps", verbose=F) #digitizing the extra specimens in a new TPS file 
Only 1 scale measure provided. Will use scale = 1  for all specimens.
Digitizing specimen 98 in filelist 
Set scale = 1 
Keep scale (y/n)? 

Many thanks! 

Chrissie 

Emma Sherratt

unread,
Aug 16, 2017, 5:37:48 AM8/16/17
to geomorph R package
Hmm, I don't think this is something you have done wrong. That sounds like something I have to look into in the function, but I'm about to head out on annual leave so I can't get to it for a week, but I'll look into it when I get back.

In the mean time you could write over all of the SCALE= lines that are wrong in order to keep moving. Sorry about this.

Emma

Adams, Dean [EEOBS]

unread,
Aug 16, 2017, 11:06:09 AM8/16/17
to Emma Sherratt, geomorph R package

Chrissie,

 

Yes, there may be an issue for us to investigate here.

 

However, to get back to your original question (one of adding new specimens), a much simpler approach is to create a second tps file and digitize the new specimens with this.  Then, when you begin your study, simply read in 2 TPS files, append the specimens into a larger matrix, and go from there. 

 

Because we are in R, there are myriad ways one can envision implementing this procedure (Note: I will ignore the obvious of ‘combine the files by hand in a text editor’, as such procedures are very prone to errors!). Below I list 3 R-based options:

 

1: Use the library ‘abind’ to combine data when reading in the files (the example is with NTS files, but the same could be used for TPS files):

 

https://github.com/geomorphR/geomorph/wiki/Reading-multiple-data-files

 

 

2: Read in the files and use ‘abind’ to combine them afterwards:

 

https://github.com/geomorphR/geomorph/wiki/Using-abind-to-Combine-3D-Arrays

 

3: Read in each datafile, convert them to matrices using ‘two.d.array’, use ‘rbind’ to combine them, and then ‘arrayspecs’ to create the 3D array of the combined datasets.

 

Hope this helps.


Dean

 

Dr. Dean C. Adams

Professor

Department of Ecology, Evolution, and Organismal Biology

       Department of Statistics

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/47a3452d-2bf0-400b-b327-a3efe83ce3b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christina Painting

unread,
Aug 16, 2017, 7:06:33 PM8/16/17
to geomorph R package
Many thanks Emma, this same thought came to me in the middle of the night so I'm glad you suggested it! Enjoy your holiday and thanks very much again. 

Christina Painting

unread,
Aug 16, 2017, 7:07:46 PM8/16/17
to geomorph R package, emma.s...@gmail.com
Hi Dean, 

Thank you very much for your suggestions, very helpful thank you. I'll go by this method of creating new TPS files in future and binding them together in R as you suggest. 

Kind regards,
Chrissie 

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages