943,963 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 4927
  • Python RSS
Feb 19th, 2006
0

Python Imaging

Expand Post »
Hi,

I am thinking about using the Python Imaging Library to display the life cycle of a hair follicle gene. This life cycle is divided into four main stages:
1. Anagen
2. Catagen
3. Telogen
4. Exogen

Gene name and corresponding life cycle stage will be stored in a csv – file or Excel Spreadsheet column.

In a picture of this life cycle, the corresponding gene stage should be highlighted in some way.

The enclosed picture is a rough draft, but should give an idea how the life cycle will look like.

Is it possible to do this with a Python script? Will I have to store different 'versions' of the life cylce, each one highlighting another stage?

As I am merely learning Python at the moment, it would be great to receive tips regarding my project, thanks!

Cheers
Juergen
Attached Thumbnails
Click image for larger version

Name:	LifeCycle.jpg
Views:	321
Size:	9.1 KB
ID:	1702  
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
juergenkemeter is offline Offline
4 posts
since Dec 2005
Feb 20th, 2006
0

Re: Python Imaging

Hi juergenkemeter,

You want to set up some kind of GUI window that displays the main hair follicle life cycle image, such that when you click the mouse (or press the space key, or enter some other input) a new layer pops up, with maybe a tinted, transparent shape over the relevant stage, and also a list of genes which are differentially expressed at that stage. And you want to set this up so that each input takes you to the next stage of the life cycle. Right?

I don't know how to do any of that! Well, maybe I know how to set up the GUI window and the main image, but I have never played with the Python imaging library. If we took a time machine back two years ago, my past self could probably have showed you how to do all this stuff with Java/Swing, but sadly, I have long since forgotten my Java roots.

The actual reason for my response is pedantic: I don't think it is correct to say "the life cycle of a hair follicle gene." Genes are not alive and they do not have "life cycles" in any conventional sense of the term (though an argument could be made for genes that undergo VDJ recombination, I suppose). A more exact way of phrasing what you mean (I think) is: "I want to display the life cycle of a hair follicle and show the differential gene expression at each phase transition."

Is this what you are trying to do?
Reputation Points: 41
Solved Threads: 31
Junior Poster
G-Do is offline Offline
146 posts
since Jun 2005
Feb 20th, 2006
0

Re: Python Imaging

Hi,
I thought about two ways to do that.

1. One basic image, which has accurate basic detail level, but no highlighting so far.
(e.g. form of a ‘6’)

2. Provide a fixed placeholder in the Sheepgenomics webpage, or provide another means to display the graphics, e.g. through clicking a Hyperlink which calls the Python imaging function, creating a corresponding image regarding the gene data
o This Python script should take the basic image, alter it according to a RULESET (accessing table gene data, i.e. in which stage the gene is at the moment), and then display the gene stage in the basic image.
o OR, if there should only be a fixed number of stages highlighted, store 4, 5, 6 different-looking images (different stages already highlighted), and then display the corresponding picture according to the underlying, stored stage data of the gene
Reputation Points: 10
Solved Threads: 0
Newbie Poster
juergenkemeter is offline Offline
4 posts
since Dec 2005
Feb 20th, 2006
0

Re: Python Imaging

Please read the next answer I have written, as I was too late to modify my previous response:

Hi,

The main aim would be to display a highlighted graphic. It is not necessary to provide gene information, too.

There will be a fixed number of stages. Therefore perhaps store various different-highlighted basic images, and then display the corresponding picture according to the gene data

I have given some thought to a suitable diagram. One option would be to use a diagram similar which you can see on page:
http://photobucket.com/albums/a19/juergenkemeter/

The diagram represents follicle development in the foetal skin (stages 0 to 8) and then the 4 main stages of the follicle growth cycle in the adult (anagen, catagen, telogen and proanagen). It has lists of the main processes involved at each stage.

The diagram is quite large which will be an issue - maybe it would have to open as a separate window.

Also, is there a possibility to underlay a highlighted section of an image with hyperlinks referencing original experiment data?

Cheers
Juergen
Reputation Points: 10
Solved Threads: 0
Newbie Poster
juergenkemeter is offline Offline
4 posts
since Dec 2005
Feb 20th, 2006
0

Re: Python Imaging

Take a look at these two PIL examples and see if you can apply them to your task ...
python Syntax (Toggle Plain Text)
  1. # using the PIL Python Image Library:
  2. # get a region of an image
  3.  
  4. import Image
  5.  
  6. # open an image file (.bmp,.jpg,.png,.gif) you have in the working folder
  7. im1 = Image.open("Donald.gif")
  8.  
  9. # set up a 100x100 pixel tuple-box(ulcX, ulcY, lrcX, lrcY)
  10. # coordinate ulcX = upper left corner X ...
  11. box = (30, 30, 130, 130)
  12.  
  13. # now crop that region and assign to im2
  14. im2 = im1.crop(box)
  15.  
  16. # brings up the modified image in a viewer, simply saves the image as
  17. # a bitmap to a temporary file and calls viewer associated with .bmp
  18. im2.show()

python Syntax (Toggle Plain Text)
  1. # using the PIL Python Image Library:
  2. # insert a small image into a larger image
  3.  
  4. import Image
  5.  
  6. def watermark(image, thumb):
  7. """inserts thumb into image, modified image is returned"""
  8. imageX, imageY = image.size
  9. thumbX, thumbY = thumb.size
  10. if thumbX < imageX and thumbY < imageY:
  11. point1 = imageX - (thumbX + 10)
  12. point2 = imageY - (thumbY + 10)
  13. point3 = imageX - 10
  14. point4 = imageY - 10
  15. image.paste(thumb, (point1, point2, point3, point4))
  16.  
  17. if __name__ == '__main__':
  18. # load two images, pick something you have
  19. # thumb1 should be smaller in size than image1
  20. image1 = Image.open('Audi.jpg')
  21. thumb1 = Image.open('Audi2.jpg')
  22. watermark(image1, thumb1)
  23. image1.show()
Last edited by vegaseat; Jan 30th, 2008 at 1:00 am. Reason: replaced php code tags
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Experimenting with For Loops (Python)
Next Thread in Python Forum Timeline: Gauge colour in python





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC