2015年8月6日 星期四

8.6 Programming is such an essential working skill

Since learning MATLAB and later on R, my capability of improving working efficiency has greatly strengthened. But I believe that what I have used is just a tiny portion of it. The true power is, well, I don't know yet.

The core of programming is to identify patterns which are repeatable. Though everything differ from each other a little bit, by forming assumptions, certain things can be grouped together. So start with simple model first, then adding extra stuff to it to let it become more flexible and specific.

By learning writing R codes and turn it to be executable using ssh command lines, I should be able to modify my previous codes to design the matrix and generate summary using that.

I should also coded up the part of typing in a bunch of cases to put them in the mytbss folder. What I need in essence is just a list of scancode. I don't have to going back and forth to edit the directory every time. Just using the list of scancode, with task specifying (e.g. -m cp ), expected rename pattern (-n s/ns/whatever), I can get a txt file with all the cases to be copied, and what I need to do is just copy and paste and there we go!

So my focus is not spending to much time with that part. With the help of codes, I will be able to focus on more important stuff.

# Can't wait. I just draft it here.
tbsscp <- function(scancode,group) {
        cbind(paste(group, scancode, ".nii", sep = ""))
}

scancode <- c("CCS001-1a11", "CCS002-1a22", "CCS003-1a33")
group <- "ns"

# Refresh: http://stackoverflow.com/questions/2470248/write-lines-of-text-to-a-file-in-r
tbsscplist <- file("tbsscplisttest.txt")
        writeLines(tbsscp(scancode, group), tbsscplist)
close(tbsscplist)

沒有留言:

張貼留言